You are on page 1of 13

Question 1 of 30 class MWC102 { public static void main (String[] args) { byte[] a = new byte[1]; long[] b = new long[1];

float[] c = new float[1]; Object[] d = new Object[1]; System.out.print(a[0]+","+b[0]+","+c[0]+","+d[0]); }} What is the result of attempting to compile and run the program?

None of the above Compile-time error Prints: 0,0,0.0,null Prints: 0,0,0,null Run-time error Question 2 of 30 class MCZ18 { public static void main (String[] args) { String a = "abcd"; // 1 String b = "'\u0041'"; // 2 String c = "\u0041"; // 3 String d = "\uD7AF"; // 4 System.out.print(a+b+c+d); // 5 }} A compile-time error is generated at which line?

3 5 1 None of the above 4 2 Question 3 of 30 class MCZ16 { public static void main (String[] args) { float a = 1; // 1 float b = 1L; // 2 float c = 1F; // 3 float d = 1.0; // 4 }} A compile-time error is generated at which line?

4 3

2 None of the above 1 Question 4 of 30 class Purple { public static void main (String []args) { int[] i = {1,2,3}; // 1 Object obj = i; // 2 i = obj; // 3 }} What is the result of attempting to compile and run the program?

Compile-time error at line 2. None of the above Compile-time error at line 3. Run-time error at line 2. Compile-time error at line 1. Run-time error at line 1. Run-time error at line 3. Question 5 of 30 class EBH106 { public static void main(String args[]) { int a = 1; a += ++a + a++; System.out.print(a); }} What is the result of attempting to compile and run the above program?

Prints: 4 Prints: 7 Prints: 5 Compile-time error Prints: 3 Prints: 6 Run-time error None of the above Question 6 of 30 class Identifiers { int i1; // 1 int _i2; // 2 int i_3; // 3 int #i4; // 4 int $i5; // 5

int %i6; // 6 int i$7; // 7 int 8i; // 8 } Compile-time errors are generated at which lines?

4 5 8 7 2 3 6 1 Question 7 of 30 class MWC103 { public static void main(String[] args) { int[] a1 = {1,2,3}; int []a2 = {4,5,6}; int a3[] = {7,8,9}; System.out.print(a1[1]+","+a2[1]+","+a3[1]); }} What is the result of attempting to compile and run the program?

Prints: 15 Prints: 18 Compile-time error Prints: 1,4,7 None of the above Prints: 2,5,8 Run-time error Prints: 3,6,9 Prints: 12 Question 8 of 30 class JMM119 { public static void main (String[] args) { int i = 0, j = 9; do { if (j < 4) {break;} else if (j-- < 7) {continue;} i++; } while (i++ < 7);

System.out.print(i + "," + j); }} What is the result of attempting to compile and run the program?

Prints: 6,5 Run-time error Prints: 6,6 Prints: 6,4 Prints: 4,7 Prints: 7,5 Prints: 8,4 Compile-time error None of the above Question 9 of 30 class MCZ13 { public static void main (String[] args) { String s = null; System.out.print(s); }} What is the result of attempting to compile and run the program?

Prints null None of the above Prints nothing Compile-time error Run-time error Question 10 of 30 class GRC4 {public static void main(String[] args) {}} // 1 class GRC5 {public static void main(String []args) {}} // 2 class GRC6 {public static void main(String args[]) {}} // 3

Compile-time error at line 3. Compile-time error at line 2. An attempt to run GRC4 from the command line fails. Compile-time error at line 1. None of the above An attempt to run GRC6 from the command line fails.

An attempt to run GRC5 from the command line fails.

Question 11 of 30 class GFM16 { static int m1 (int i1, int i2) { int i3; if (i1 > 0) {i3 = i1 + i2;} return i3; } public static void main(String[] args) { System.out.println(m1(1,2)); }} What is the result of attempting to compile and run the program?

None of the above Prints: 0 Run-time error Prints: 1 Compile-time error Question 12 of 30 class GFM12 { static int x; public static void main(String[] args) { int y; System.out.println("x="+x); System.out.println("y="+y); }} What is the result of attempting to compile

// // // // //

1 2 3 4 5

and run the program?

Compile-time error at line 1. Compile-time error at line 5. Compile-time error at line 2. Compile-time error at line 4. Compile-time error at line 3. Question 13 of 30 class GFM15 { static int a; static float b; static double c; static boolean d; static String s; public static void main(String[] args) { System.out.println(a+","+b+","+c+","+d+","+s); }} What is the result of attempting to compile and run the program?

Prints: 0,0.0,0.0,true, Prints: 0,0.0,0.0,false, None of the above Prints: 0,0,0,false, Prints: 0,0.0,0.0,true,null Prints: 0,0.0,0.0,false,null Run-time error Compile-time error Prints: 0,0,0,false,null Question 14 of 30 class GFC401 { static int m1(int x) {return ++x;} public static void main (String[] args) { int x = 1; int y = m1(x); System.out.println(x + "," + y); }} What is the result of attempting to compile and run the program?

Prints: 3,2 Compile-time error Prints: 2,1 Prints: 2,2 None of the above Run-time error Prints: 1,2 Prints: 1,1 Question 15 of 30 class MCZ23 { public static void main (String[] args) { // Insert code here. }}

boolean b3 = 'true' boolean b5 = 0 boolean b1 = true; None of the above

boolean b2 = TRUE boolean b4 = "TRUE" Question 16 of 30 class JMM103 { public static void main(String args[]) { for (int i = 0; i < 5 ;i++) { switch(i) { 0: System.out.print("v ");break; 1: System.out.print("w "); 2: System.out.print("x ");break; 3: System.out.print("y "); 4: System.out.print("z ");break; }}}} What is the result of attempting to compile and run the program?

Prints: v w w x y y z Run-time error. Prints: v w x x y z z Compile-time error. Prints: v w x y z None of the above. Question 17 of 30 class MWC101 { public static void main(String[] args) { int[] a1 = new int[]; // 1 int a2[] = new int[5]; // 2 int[] a3 = new int[]{1,2}; // 3 int []a4 = {1,2}; // 4 int[] a5 = new int[5]{1,2,3,4,5}; // 5 }} Compile-time errors are generated at which lines?

1 2 4 5 3 Question 18 of 30 class GFC301 { private String name; public GFC301(String name) {this.name = name;} public void setName(String name) {this.name = name;} public String getName() {return name;} public static void m1(GFC301 r1, GFC301 r2) { r1.setName("Bird"); r2 = r1;

} public static void main (String[] args) { GFC301 pet1 = new GFC301("Dog"); GFC301 pet2 = new GFC301("Cat"); m1(pet1,pet2); System.out.println(pet1.getName() + "," + pet2.getName()); }} What is the result of attempting to compile and run the program?

Prints: Dog,Bird None of the above Prints: Bird,Cat Compile-time error Prints: Bird,Bird Run-time error Prints: Dog,Cat Question 19 of 30 class GFM14 { static byte a; static short b; static char c; static int d; static long e; static String s; public static void main(String[] args) { System.out.println(a+","+b+","+(int)c+","+d+","+e+","+s); }}

Prints: 0,0, ,0,0, Run-time error Compile-time error Prints: 0,0,0,0,0, Prints: 0,0,0,0,0,null None of the above Question 20 of 30 class EBH105 { static int m(int i) {System.out.print(i + ","); return 0;} public static void main (String[] args) { int i = 0; i = i++ + m(i); System.out.print(i); }} What is the result of attempting to compile and run the above program?

Prints: 1,1 Prints: 0,0 None of the above

Compile-time error Prints: 1,0 Prints: 0,1 Run-time error Question 21 of 30 class GFM17 { int x; public static void main(String[] args) { int y = 0; System.out.print(x+","); System.out.print(y); }} What is the result of attempting to compile

// // // // //

1 2 3 4 5

and run the program?

Compile-time error at line 5. Compile-time error at line 2. Prints: 0,0 Run-time error Compile-time error at line 1. Compile-time error at line 4. Compile-time error at line 3. None of the above Question 22 of 30 class JMM107 { public static void main(String[] args) { boolean b = true; if (b = false) {System.out.print("A"); } else if (b) {System.out.print("B"); } else {System.out.print("C");} }} What is the result of attempting to compile and run the program?

Prints: C Prints: A Compile-time error None of the above Run-time error Prints: B

Question 23 of 30 class MWC105 { static boolean b1; public static void main(String[] args) { boolean[] array = new boolean[1]; boolean b2; System.out.print(b1+","); System.out.print(array[0]+","); System.out.print(b2); }} What is the result of attempting to compile and run the program?

Prints: false,true,false Prints: false,false,false Compile-time error Run-time error Prints: true,true,true None of the above Prints: null,null,null Question 24 of 30 class GFM11{ public static void main (String[] args) { int x,y,z; System.out.println(x+y+z); }} What is the result of attempting to compile and run the program?

Prints: null Prints: 0 Run-time error Prints an undefined value. Prints nothing. Compile-time error Question 25 of 30 class MCZ20 { public static void main (String[] args) { // Insert code here. }} Which of the following lines can be inserted at the specified location without g enerating a compile-time error?

None of the above

String d = '\uabcd'; String b = 'abc'; String c = '\u0041'; String a = 'a'; Question 26 of 30 class MCZ19 { public static void main (String[] args) { String a1 = null; // 1 String b1 = 'null'; // 2 String c1 = "null"; // 3 String d1 = "'null'"; // 4 }} A compile-time error is generated at which line?

1 None of the above 3 4 2 Question 27 of 30 class GFC100 { public static void main(String[] args) { final short s1 = 1; // 1 final char c1 = 1; // 2 byte b1 = s1; // 3 byte b2 = c1; // 4 byte b3 = 1; // 5 byte b4 = 1L; // 6 byte b5 = 1.0; // 7 byte b6 = 1.0d; // 8 }} Compile-time errors are generated at which lines?

2 4 7 1 8 5 3 6 Question 28 of 30

class GFM13 { static byte a; static short b; static char c; static int d; static long e; static String s; public static void main(String[] args) { System.out.println(a+b+c+d+e+s); }} What is the result of attempting to compile and run the program?

Prints: 00000 Prints: 00000null Compile-time error None of the above Run-time error Prints: 0null Prints: null Prints: 0 Question 29 of 30 Which of these words belong to the set of Java keywords?

struct implements virtual union goto friend typedef ifdef const Question 30 of 30 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?

Compile-time error Prints: 1, 2, 3, 4, 8,

Prints: 3, 4, 1, 2, 11, Run-time error None of the above Prints: 1, 2, 3, 4, 11,

You might also like