What is the output of the code snippet?
Anonymous Quiz
8%
true, 10, true
33%
true, 20, false
9%
false, 20, true
14%
false, 20, false
7%
false, 20, true
29%
The code will not compile because of line 5
Code snippet:
3: for(int i=0; i<10 ; ) {
4: i = i++;
5: System.out.println("Hello World");
6: }
How many times will the following code print "Hello World"?
Anonymous Quiz
24%
9
33%
10
6%
11
20%
The code will not compile because of line 3
2%
The code will not compile because of line 5
15%
The code contains an infinite loop and does not terminate
Code snippet:
3: byte a = 40, b = 50;
4: byte sum = (byte) a + b;
5: System.out.println(sum);
3: byte a = 40, b = 50;
4: byte sum = (byte) a + b;
5: System.out.println(sum);
What is the output of the code?
Anonymous Quiz
2%
40
3%
50
50%
90
35%
The code will not compile because of line 4
9%
An undefined value
Code snippet:
3: int x = 1, y = 15;
4: while x < 10
5: y––;
6: x++;
7: System.out.println(x+", "+y);
What is the output of the code snippet?
Anonymous Quiz
9%
10, 5
16%
10, 6
8%
11, 5
11%
The code will not compile because of line 3
36%
The code will not compile because of line 4
20%
The code contains an infinite loop and does not terminate
Code snippet:
3: do {
4: int y = 1;
5: System.out.print(y++ + " ");
6: } while(y <= 10);
What is the output of the code snippet?
Anonymous Quiz
13%
1 2 3 4 5 6 7 8 9
35%
1 2 3 4 5 6 7 8 9 10
16%
1 2 3 4 5 6 7 8 9 10 11
20%
The code will not compile because of line 6
16%
The code contains an infinite loop and does not terminate
Code snippet:
3: boolean keepGoing = true;
4: int result = 15, i = 10;
5: do {
6: i--;
7: if(i==8) keepGoing = false;
8: result -= 2;
9: } while(keepGoing);
10: System.out.println(result);
What is the output of the code snippet?
Anonymous Quiz
6%
7
10%
9
11%
10
38%
11
10%
15
25%
The code will not compile because of line 8
Code snippet:
3: int m = 9, n = 1, x = 0;
4: while(m > n) {
5: m--;
6: n += 2;
7: x += m + n;
8: }
9: System.out.println(x);
What is the result of the code snippet above?
Anonymous Quiz
27%
11
8%
13
18%
23
25%
36
8%
50
13%
The code will not compile because of line 7
Code snippet:
3: final char a = 'A', d = 'D';
4: char grade = 'B';
5: switch(grade) {
6: case a:
7: case 'B': System.out.print("great");
8: case 'C': System.out.print("good"); break;
9: case d:
10: case 'F': System.out.print("not good");
11: }
What is the result of the code snippet?
Anonymous Quiz
23%
great
34%
greatgood
17%
The code will not compile because of line 3
14%
The code will not compile because of line 6
12%
The code will not compile because of line 6 and 9
Code snippet:
public class Lion {
public void roar(String roar1, StringBuilder roar2) {
roar1.concat("!!!");
roar2.append("!!!");
}
public static void main(String[] args) {
String roar1 = "roar";
StringBuilder roar2 = new StringBuilder("roar");
new Lion().roar(roar1, roar2);
System.out.println(roar1 + " " + roar2);
} }
What is the result of the code?
Anonymous Quiz
18%
roar roar
29%
roar roar!!!
11%
roar!!! roar
30%
roar!!! roar!!!
6%
An exception is thrown
6%
The code does not compile
Code snippet:
3: String s = "purr";
4: s.toUpperCase();
5: s.trim();
6: s.substring(1, 3);
7: s += " two";
8: System.out.println(s.length());
What is the result of the code?
Anonymous Quiz
9%
2
26%
4
42%
8
7%
10
9%
An exception is thrown
7%
The code does not compile
Code snippet:
13: String a = "";
14: a += 2;
15: a += 'c';
16: a += false;
17: if ( a == "2cfalse") System.out.println("==");
18: if ( a.equals("2cfalse")) System.out.println("equals");