Code snippet:
String s1 = "Java";
String s2 = "Java";
StringBuilder sb1 = new StringBuilder();
sb1.append("Ja").append("va");
System.out.println(s1 == s2);
System.out.println(s1.equals(s2));
System.out.println(sb1.toString() == s1);
System.out.println(sb1.toString().equals(s1));
What is the result of the code above?
Anonymous Quiz
15%
true is printed out exactly once.
22%
true is printed out exactly twice.
31%
true is printed out exactly three times.
16%
true is printed out exactly four times.
16%
The code does not compile
Code snippet:
1: public class _C {
2: private static int $;
3: public static void main(String[] main) {
4: String a_b;
5: System.out.print($);
6: System.out.print(a_b);
7: } }
What is the result of the class?
Anonymous Quiz
22%
Compiler error on line 1
32%
Compiler error on line 2
10%
Compiler error on line 4
8%
Compiler error on line 5
12%
Compiler error on line 6
9%
0null
6%
nullnull
Code snippet:
// Line n1
switch (cardVal) {
case 4: case 5: case 6:
case 7: case 8:
System.out.println("Hit");
break;
case 9: case 10: case 11:
System.out.println("Two");
break;
case 15: case 16:
System.out.println("Sur");
break;
default:
System.out.println("Win");
}
Which code fragment can be inserted at Line n1, independently, enable to print 'Win'?
Anonymous Quiz
10%
int cardVal = 6;
9%
int cardVal = 10;
26%
int cardval = 12;
9%
int cardVal = 14.;
28%
int cardVal = 18;
18%
int cardVal = 20
What is the output of the following code? (Choose all that apply)
Anonymous Poll
13%
2
30%
4
24%
The code will not compile because of line 3
38%
The code will not compile because of line 5
21%
The code will not compile because of line 7
26%
The code will not compile because of line 11
12%
The output cannot be determined from the code provided
Code snippet:
1: public class FeedingSchedule {
2: public static void main(String[] args) {
3: boolean keepGoing = true;
4: int count = 0;
5: int x = 3;
6: while(count++ < 3) {
7: int y = (1 + 2 * count) % 3;
8: switch(y) {
9: default:
10: case 0: x -= 1; break;
11: case 1: x += 5;
12: }
13: }
14: System.out.println(x);
15: } }
What is the output of the code above?
Anonymous Quiz
9%
4
8%
5
25%
6
19%
7
10%
13
29%
The code will not compile because of line 7
Code snippet:
13: System.out.print("a");
14: try {
15: System.out.print("b");
16: throw new IllegalArgumentException();
17: } catch (RuntimeException e) {
18: System.out.print("c");
19: } finally {
20: System.out.print("d");
21: }
22: System.out.print("e");
What is the output of the snippet above?
Anonymous Quiz
44%
abcde
27%
abde
5%
abce
8%
abe
5%
The code does not compile
11%
An uncaught excpetion is thrown
What is the result of the following program?
1: public class MathFunctions {
2: public static void addToInt(int x, int amountToAdd) {
3: x = x + amountToAdd;
4: }
5: public static void main(String[] args) {
6: int a = 15;
7: int b = 10;
8: MathFunctions.addToInt(a, b);
9: System.out.println(a); } }|
What is the result of the program above?
Anonymous Quiz
5%
10
41%
15
33%
25
12%
Compiler error on line 3
7%
Compiler error on line 8
2%
None of the above
What is the result of the following code?
int[] array = {6,9,8};
List<Integer> list = new ArrayList<>();
list.add(array[0]);
list.add(array[2]);
list.set(1, array[1]);
list.remove(0);
System.out.println(list);
What is the result of the following code?
Anonymous Quiz
15%
[8]
44%
[9]
16%
Something like [Ljava.lang.String;@160bc7c0
13%
An exception is thrown
12%
The code does not compile
What is the output of the following code?
public class Deer {
public Deer() { System.out.print("Deer"); }
public Deer(int age) { System.out.print("DeerAge"); }
private boolean hasHorns() { return false; }
public static void main(String[] args) {
Deer deer = new Reindeer(5);
System.out.println(","+deer.hasHorns());
}
}
class Reindeer extends Deer {
public Reindeer(int age) { System.out.print("Reindeer"); }
public boolean hasHorns() { return true; }
}
What is the output of the following program?
public class BearOrShark {
public static void main(String[] args) {
int luck = 10;
if((luck>10 ? luck++: --luck)<10) {
System.out.print("Bear");
} if(luck<10) System.out.print("Shark");
} }