What is the result of the code?
Anonymous Quiz
20%
abbaaccc
37%
abbaccca
13%
bbaaaccc
7%
bbaaccca
17%
An exception is thrown
6%
The code does not compile
Code snippet:
2: String s1 = "java";
3: StringBuilder s2 = new StringBuilder("java");
4: if (s1 == s2)
5: System.out.print("1");
6: if (s1.equals(s2))
7: System.out.print("2");
What is the result of the code?
Anonymous Quiz
9%
1
47%
2
15%
12
9%
No output is printed
6%
An exception is thrown
13%
The code does not compile
Code snippet:
import java.util.Arrays;
public class Main {
public static void main(String []args){
int[] random = { 6, -4, 100, 12, 0, -10 };
int x = 12;
int y = Arrays.binarySearch(random, x);
System.out.println(y);
}
}
What is the result of code execution?
Anonymous Quiz
6%
2
29%
3
13%
4
7%
6
15%
-3
12%
An exception is thrown
17%
The code does not compile
Code snippet:
4: List<Integer> list = Arrays.asList(10, 4, -1, 5);
5: Collections.sort(list);
6: Integer array[] = list.toArray(new Integer[4]);
7: System.out.println(array[0]);
What is the result of the code snippet?
Anonymous Quiz
44%
-1
17%
10
12%
Compiler error on line 4
7%
Compiler error on line 5
15%
Compiler error on line 6
5%
An exception is thrown
Code fragment:
3: ArrayList<Integer> values = new ArrayList<>();
4: values.add(4);
5: values.add(5);
6: values.set(1, 6);
7: values.remove(0);
8: for (Integer v : values) System.out.print(v);
What is the result of the statements above?
Anonymous Quiz
10%
4
7%
5
43%
6
8%
46
9%
45
10%
An exception is thrown
15%
The code does not compile
Code snippet:
LocalDate date = LocalDate.parse("2018-04-30", DateTimeFormatter.ISO_LOCAL_DATE);
date.plusDays(2);
date.plusHours(3);
System.out.println(date.getYear() + " " + date.getMonth() + " "+ date.getDayOfMonth());
What is the output of the code?
Anonymous Quiz
9%
2018 APRIL 2
26%
2018 APRIL 30
36%
2018 MAY 2
20%
The code does not compile
8%
A runtime exception is thrown
Code snippet:
6: List<String> list = new ArrayList<String>();
7: list.add("one");
8: list.add("two");
9: list.add(7);
10: for(String s : list) System.out.print(s);
What is the result of the statements?
Anonymous Quiz
12%
onetwo
23%
onetwo7
14%
onetwo followed by an exception
42%
Compiler error on line 9
8%
Compiler error on line 10
Code snippet:
public class BirdDisplay {
public static void main(String[] name) {
System.out.println(name[1]);
} }
Given the class above, which of the following calls print out 'Blue Jay'?
Anonymous Quiz
7%
java BirdDisplay Sparrow Blue Jay
27%
java BirdDisplay Sparrow "Blue Jay"
8%
java BirdDisplay Blue Jay Sparrow
8%
java BirdDisplay "Blue Jay" Sparrow
8%
java BirdDisplay.class Sparrow "Blue Jay"
7%
java BirdDisplay.class "Blue Jay" Sparrow
35%
Does not compile
Code snippet:
1: public class Salmon {
2: int count;
3: public void Salmon() {
4: count = 4;
5: }
6: public static void main(String[] args) {
7: Salmon s = new Salmon();
8: System.out.println(s.count);
9: } }
What does the code output?
Anonymous Quiz
27%
0
37%
4
18%
Compilation fails on line 3
6%
Compilation fails on line 4
5%
Compilation fails on line 7
7%
Compilation fails on line 8
Code snippet
1: public class TernaryTester {
2: public static void main(String[] args) {
3: int x = 5;
4: System.out.println(x > 2 ? x < 4 ? 10 : 8 : 7);
5: }}
What is the output of the code?
Anonymous Quiz
9%
5
8%
4
15%
10
26%
8
8%
7
34%
The code will not compile because of line 4
Code snippet:
3: boolean x = true, z = true;
4: int y = 20;
5: x = (y != 10) ^ (z=false);
6: System.out.println(x+", "+y+", "+z);