Amazon Interview Question for Testing / Quality Assurances


Team: QAE
Country: India
Interview Type: In-Person




Comment hidden because of low score. Click to expand.
1
of 1 vote

1. Check leap year like: 25-02-2010, shld output 29-02-2010
2. Normal testcases like what you mentioned
3. Month change
-> 31 days months
-> 30 days months
-> 28 days months
4. Year change like 28-12-2013 - 01-01-2013
Other: The format should always be dd/mm/yyyy

- James Anderson April 22, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Hi U forget to Add leap year , 29 days in FEB

- MVVSK April 26, 2014 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

Bounday Values should be

Year and month change
A. 27/12/2012 it should return 31/12/2012
B. 28/12/2012 it should return 1/1/2013
Leap year check
1. 25/02/2012 it should return 29/02/2012
2. 26/02/2012 it should return 01/03/2012
3. 25/02/2013 it should return 01/03/2013
4. 24/02/2013 it should return 28/02/2013
No need to check 31st as we already tested it on scenario A,B
Check 30 days change also.

- abhay40711cs July 29, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Few more cases
1. Test for year end dates - 12/31/2012 - 01/04/2013
2. Test for month end dates, leap year

- Siva April 23, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

String input = "28/12/9999";
String[] splitArray = input.split("/");
Integer date = Integer.parseInt(splitArray[0]);
Integer month = Integer.parseInt(splitArray[1]);
Integer year = Integer.parseInt(splitArray[2]);

boolean leapYear = year%4 == 0 ? true : false;

boolean is31Days = false;

if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
is31Days = true;

boolean isfeb = month == 2? true : false;
date = date+4;
if((is31Days && date > 31))
{
month +=1; date = date - 31;
}
else if(!is31Days && date > 30)
{
month +=1; date = date - 31;
}
else if ((isfeb && leapYear && date > 29 ) )
{
month +=1; date = date - 29;
}
else if (isfeb && !leapYear && date > 28 ){
month +=1; date = date - 28 ;
}
if(month == 13){
month = 1;
year +=1;
}

System.out.print((date.toString().length()==1?"0":"") + date.toString() + "/" + (month.toString().length() == 1 ? "0" : "")+month.toString()+"/"+year.toString());

- MVVSK April 26, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Hi,

I guess there is a small mistake in the following statement.

else if(!is31Days && date > 30)
{
month +=1; date = date - 31;
}

it should be date - 30; instead of date - 31;

- Anonymous August 21, 2014 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More