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.
(1) & (3)
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.
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.