Interview Question for Front-end Software Engineers


Country: India
Interview Type: Written Test




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

This is quite easy, Here is right implementation

public class SeqTest { 

	public static void main(String args[]) { 
		for(int i = 1; i <= 50; i++) {
			if ( (i%3 == 0) && (i%5 == 0) ) System.out.println("ATGC"); 
			else if(i % 3 == 0) System.out.println("DNA"); 
			else if(i % 5 == 0) System.out.println("RNA"); 
			else System.out.println(i); 
		} 
	}
	
}

- Manoj Sharma December 20, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

public class Test{
public static void main(String args[]){
for(int i=1;i<=50;i++){
if(i%3==0){
if(i%5==0){
System.out.println("ATGC");
continue;
}
System.out.println("DNA");
}
else if(i%5==0){
System.out.println("RNA");
}
else{
System.out.println(i);
}
}
}
}

- Anonymous December 20, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

Bug 1: condition “else if(i%(3+5)==0)” should be replaced with “if(i%3==0&&i%5==0)”

Bug 2: condition if(i%3==0&&i%5==0) should be first line in the program.

Bug 3: Last line should be System.out.println(i); instead of System.out.println(“1 to 50”);

- Sandeep January 13, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

bug1: i%(3+5) should be i%15
bug2: i%15 should be before i%3 and i%5 because any number that is divisible by 15 is automatically divisible by 3 and 5. So the specialized case need to be first.
bug3:??

- mahesh December 20, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class SeqTest {

public static void main(String args[]) {

for(int i = 1; i <= 50; i++) {
if(i % 3 == 0) System.out.println("DNA");
else if(i % 5 == 0) System.out.println("RNA");
else if(i % (3+5) == 0) System.out.println("ATGC");
else System.out.println(“1 to 50”);
}
}
}

- Anonymous October 29, 2020 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class SeqTest {

public static void main(String args[]) {

for(int i = 1; i <= 50; i++) {
if(i % 3 == 0) System.out.println("DNA");
else if(i % 5 == 0) System.out.println("RNA");
else if(i % (3+5) == 0) System.out.println("ATGC");
else System.out.println(“1 to 50”);
}
}
}

- Anonymous October 29, 2020 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class SeqTest {

public static void main(String args[]) {
for(int i = 1; i <= 50; i++) {
if ( (i%3 == 0) && (i%5 == 0) ) System.out.println("ATGC");
else if(i % 3 == 0) System.out.println("DNA");
else if(i % 5 == 0) System.out.println("RNA");
else System.out.println(i);
}

- Anonymous October 29, 2020 | Flag Reply


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