class EBH019 {
public static void main (String args[]) {
int i1 = 0xffffffff, i2 = i1 << 1;
int i3 = i1 >> 1, i4 = i1 >>> 1;
System.out.print(Integer.toHexString(i2) + ",");
System.out.print(Integer.toHexString(i3) + ",");
System.out.print(Integer.toHexString(i4));
}}
What is the result of attempting to compile and run the program?
| a. | Prints: ffffffff,ffffffff,ffffffff |
| b. | Prints: ffffffff,ffffffff,7fffffff |
| c. | Prints: ffffffff,7fffffff,ffffffff |
| d. | Prints: ffffffff,7ffffffe,7ffffffe |
| e. | Prints: fffffffe,ffffffff,ffffffff |
| f. | Prints: fffffffe,ffffffff,7fffffff |
| g. | Prints: fffffffe,7fffffff,ffffffff |
| h. | Prints: fffffffe,7fffffff,7fffffff |
| i. | Run-time error |
| j. | Compile-time error |
| k. | None of the above |
class EBH011 {
public static void main (String[] args) {
float a = Float.POSITIVE_INFINITY;
double b = Double.POSITIVE_INFINITY;
double c = Double.NaN;
System.out.print((a == b)+","+(c == c)+","+(c != c));
}}
What is the result of attempting to compile and run the program?
| a. | Prints: false,false,false |
| b. | Prints: false,false,true |
| c. | Prints: false,true,false |
| d. | Prints: false,true,true |
| e. | Prints: true,false,false |
| f. | Prints: true,false,true |
| g. | Prints: true,true,false |
| h. | Prints: true,true,true |
| i. | Run-time error |
| j. | Compile-time error |
| k. | None of the above |
class EBH012 {
public static void main (String[] args) {
byte x = 3, y = 5;
System.out.print((-x == ~x + 1)+","+(-y == ~y + 1));
}}
What is the result of attempting to compile and run the program?
| a. | Prints: false,false |
| b. | Prints: false,true |
| c. | Prints: true,false |
| d. | Prints: true,true |
| e. | Run-time error |
| f. | Compile-time error |
| g. | None of the above |
class EBH013 {
public static void main (String[] args) {
byte x = 3, y = 5;
System.out.print((~x == -x - 1)+","+(~y == -y - 1));
}}
What is the result of attempting to compile and run the program?
| a. | Prints: false,false |
| b. | Prints: false,true |
| c. | Prints: true,false |
| d. | Prints: true,true |
| e. | Run-time error |
| f. | Compile-time error |
| g. | None of the above |
class EBH014 {
public static void main (String[] args) {
byte x = 3, y = 5;
System.out.print((y % x) + ",");
System.out.print(y == ((y/x)*x + (y%x)));
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 1,true |
| b. | Prints: 2,true |
| c. | Prints: 1,false |
| d. | Prints: 2,false |
| e. | Run-time error |
| f. | Compile-time error |
| g. | None of the above |
class Color {}
class Red extends Color {}
class Blue extends Color {}
class A {
public static void main (String[] args) {
Color color1 = new Red(); Red color2 = new Red();
boolean b1 = color1 instanceof Color;
boolean b2 = color1 instanceof Blue;
boolean b3 = color2 instanceof Blue;
System.out.print(b1+","+b2+","+b3);
}}
What is the result of attempting to compile and run the program?
| a. | false,false,false |
| b. | false,false,true |
| c. | false,true,false |
| d. | false,true,true |
| e. | true,false,false |
| f. | true,false,true |
| g. | true,true,false |
| h. | true,true,true |
| i. | Run-time error |
| j. | Compile-time error |
| k. | None of the above |
class EBH020 {
public static void main (String[] args) {
int a = 1 | 2 ^ 3 & 5;
int b = ((1 | 2) ^ 3) & 5;
int c = 1 | (2 ^ (3 & 5));
System.out.print(a + "," + b + "," + c);
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 0,0,0 |
| b. | Prints: 0,0,3 |
| c. | Prints: 0,3,0 |
| d. | Prints: 0,3,3 |
| e. | Prints: 3,0,0 |
| f. | Prints: 3,0,3 |
| g. | Prints: 3,3,0 |
| h. | Prints: 3,3,3 |
| i. | Run-time error |
| j. | Compile-time error |
| k. | None of the above |
class EBH025 {
public static void main (String args[]) {
int i1 = 0xffffffff, i2 = i1 << 33;
int i3 = i1 << (33 & 0x1f);
System.out.print(Integer.toHexString(i2) + ",");
System.out.print(Integer.toHexString(i3));
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 0,0 |
| b. | Prints: 0,fffffffe |
| c. | Prints: 0,ffffffff |
| d. | Prints: ffffffff,ffffffff |
| e. | Prints: ffffffff,fffffffe |
| f. | Prints: fffffffe,ffffffff |
| g. | Prints: fffffffe,fffffffe |
| h. | Run-time error |
| i. | Compile-time error |
| j. | None of the above |
class EBH001 {
static int m(int i) {
System.out.print(i + ", ");
return i;
}
public static void main(String s[]) {
m(m(1) - m(2) + m(3) * m(4));
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 1, 2, 3, 4, 8, |
| b. | Prints: 1, 2, 3, 4, 11, |
| c. | Prints: 3, 4, 1, 2, 11, |
| d. | Run-time error |
| e. | Compile-time error |
| f. | None of the above |
class EBH002 {
static int m(int i) {
System.out.print(i + ", ");
return i;
}
public static void main(String s[]) {
m(m(1) + m(2) % m(3) * m(4));
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 1, 2, 3, 4, 0, |
| b. | Prints: 1, 2, 3, 4, 3, |
| c. | Prints: 1, 2, 3, 4, 9, |
| d. | Prints: 1, 2, 3, 4, 12, |
| e. | Prints: 2, 3, 4, 1, 9, |
| f. | Prints: 2, 3, 4, 1, 3, |
| g. | Run-time error |
| h. | Compile-time error |
| i. | None of the above |
class EBH005 {
public static void main (String[] s) {
byte b = 127; b <<= 2;
System.out.println(b);
}}
What is the result of attempting to compile and run the program?
| a. | Prints: -4 |
| b. | Prints: -3 |
| c. | Prints: -2 |
| d. | Prints: 0 |
| e. | Prints: 1 |
| f. | Prints: 127 |
| g. | Prints: 508 |
| h. | Run-time error |
| i. | Compile-time error |
| j. | None of the above |
class EBH007{
public static void main (String[] s) {
byte b = 5;
System.out.println(b<<33);
}}
What is the result of attempting to compile and run the program?
| a. | Prints: -1 |
| b. | Prints: 0 |
| c. | Prints: 1 |
| d. | Prints: 5 |
| e. | Prints: 10 |
| f. | Run-time error |
| g. | Compile-time error |
| h. | None of the above |
class EBH015 {
public static void main (String[] args) {
System.out.print((new Object() instanceof Object)+",");
System.out.print((new Object() instanceof String)+",");
System.out.print((new String() instanceof Object));
}}
What is the result of attempting to compile and run the program?
| a. | Prints: false,false,false |
| b. | Prints: false,false,true |
| c. | Prints: false,true,false |
| d. | Prints: false,true,true |
| e. | Prints: true,false,false |
| f. | Prints: true,false,true |
| g. | Prints: true,true,false |
| h. | Prints: true,true,true |
| i. | Run-time error |
| j. | Compile-time error |
| k. | None of the above |
class EBH023 {
static String m1(boolean b){return b?"T":"F";}
public static void main(String [] args) {
boolean b1 = false?false:true?false:true?false:true;
boolean b2 = false?false:(true?false:(true?false:true));
boolean b3 = ((false?false:true)?false:true)?false:true;
System.out.println(m1(b1) + m1(b2) + m1(b3));
}}
What is the result of attempting to compile and run the program?
| a. | Prints: FFF |
| b. | Prints: FFT |
| c. | Prints: FTF |
| d. | Prints: FTT |
| e. | Prints: TFF |
| f. | Prints: TFT |
| g. | Prints: TTF |
| h. | Prints: TTT |
| i. | Run-time error |
| j. | Compile-time error |
| k. | None of the above |
class EBH024 {
public static void main(String[] args) {
int i1 = 15;
String b1 = (i1>30)?"Red":(i1>20)?"Green":(i1>10)?"Blue":"Violet";
String b2 = (i1>30)?"Red":((i1>20)?"Green":((i1>10)?"Blue":"Violet"));
System.out.println(b1 + "," + b2);
}}
What is the result of attempting to compile and run the program?
| a. | Prints: Red,Red |
| b. | Prints: Green,Green |
| c. | Prints: Blue,Blue |
| d. | Prints: Violet,Violet |
| e. | Prints: Blue,Violet |
| f. | Prints: Violet,Blue |
| g. | Prints: Blue,Green |
| h. | Prints: Green,Blue |
| i. | Run-time error |
| j. | Compile-time error |
| k. | None of the above |
class EBH003 {
static int m(int i) {
System.out.print(i + ", ");
return i;
}
public static void main(String s[]) {
m(m(~1) + m(1|2) + m(1&2) + m(1^3) + m(1<<1));
}}
What is the result of attempting to compile and run the program?
| a. | Prints: -2, 3, 0, 3, 0, 6 |
| b. | Prints: -2, 3, 0, 2, 1, 4 |
| c. | Prints: -2, 3, 0, 2, 2, 5 |
| d. | Prints: -2, 3, 0, 3, 2, 6 |
| e. | Prints: -1, 3, 0, 3, 2, 7 |
| f. | Prints: -2, 0, 3, 3, 0, 6 |
| g. | Prints: -1, 0, 3, 2, 1, 4 |
| h. | Prints: -2, 0, 3, 2, 2, 5 |
| i. | Prints: -2, 0, 3, 3, 2, 6 |
| j. | Prints: -1, 0, 3, 3, 2, 7 |
| k. | Run-time error |
| l. | Compile-time error |
| m. | None of the above |
class EBH021 {
public static void main(String[] args) {
System.out.print((-1 & 0x1f) + "," + (8 << -1));
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 0,0 |
| b. | Prints: -1,4 |
| c. | Prints: 0x1f,8 |
| d. | Prints: 31,16 |
| e. | Run-time error |
| f. | Compile-time error |
| g. | None of the above |