## Amazon Interview Question for Testing / Quality Assurances

• 1
of 1 vote

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

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

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

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.

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

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());

Comment hidden because of low score. Click to expand.
0

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;

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.

### 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.