Home Tutorial Java Scjp Part2 SCJP Module-2 Question-8

 
 

SCJP Module-2 Question-8
Posted on: July 8, 2010 at 12:00 AM
This program refreshes your concepts of Core Java and also helps in preparation of SCJP Examination

What is the Output of the following code :

public class Example8 {
public static void main(String[] args) {
System.out.println(check(null, 3));
System.out.println(check("hello", 7));
System.out.println(check("bye", 2));
System.out.println(check("hai", 3));
}

public static int check(String a, int n) {
if (n == 7)
return n;
else if (n == 3) {
if (a != null)
return 5;
} else if (n == 5 && a != null) {
if (a.equals("hai"))
return 3;
else if (a.equals("bye"))
return 4;
}
return -3;
}
}

What is the output of the following code :

1. -3

2. 7

3. -3 7 -3 5

4.  5

Answer :

(3)

Related Tags for SCJP Module-2 Question-8:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.