11)
What will be the output of following program?
public class prg {
public static void main(String[] args) {
System.out.println( (byte) 0xff);
}
}
- -1
- 255
- 65535
- 0xff
Correct Answer: 1
-1
0xff is the maximum value of a byte. And in Decimal maximum value of a byte is -1.
12
What will be the output of following program?
public class prg {
public static void main(String[] args) {
System.out.println( (int)(char)(byte) 0xff);
}
}
- -1
- 255
- 65535
- 0xff
13
Which is the correct declaration of a boolean variable?
- boolean isAdult='false';
- boolean isAdult=0;
- boolean isAdult="false";
- boolean isAdult=false;
Correct Answer: 4
boolean isAdult=false;
A boolean variable can store only true or false.