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

 
 

Share on Google+Share on Google+
SCJP Module-2 Question-6
Posted on: July 7, 2010 at 12:00 AM
Advertisement
This given sample program checks your core Java concepts and is also useful for SCJP exam preparation.

Which are correct input-output options :

public class Example6{
public static void main(String args[])
{
public int check(char a) {
if (a <= 'N') {
if (a == 'E')
return 2;
return 1;
} else if (a == 'S')
return 3;
else if (a == 'W')
return 4;
return 0; }
}
}

Options are :

(1) a='A' output=1.

(2)Compile error.

(3) a='X' output=0,

(4)a='D' output=0.

Answer :

(1) & (3)

Explanation :

Since 'Ascii' value of 'D' is less than 'Ascii' value of 'N', so it's output will be 1.That's why it(4) is not correct option to choose.

Advertisement

Related Tags for SCJP Module-2 Question-6:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 7, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com