What is the output of the program from previous message?
Anonymous Quiz
19%
Bear
14%
Shark
42%
BearShark
12%
The code will not compile because of line 4
6%
The code will not compile because of line 6
7%
The code compiles without issue but does not produce any output
What is the result of the following program?
1: public class Egret {
2: private String color;
3: public Egret() {
4: this("white");
5: }
6: public Egret(String color) {
7: color = color;
8: }
9: public static void main(String[] args) {
10: Egret e = new Egret();
11: System.out.println("Color:" + e.color);
12: }
13: }
What is the result of the program above?
Anonymous Quiz
9%
Color:
22%
Color:null
38%
Color:White
20%
Compiler error on line 4
6%
Compiler error on line 10
5%
Compiler error on line 11
What is the output of the following program?
public class WaterBottle {
private String brand;
private boolean empty;
public static void main(String[] args) {
WaterBottle wb = new WaterBottle();
System.out.print("Empty = " + wb.empty);
System.out.print(", Brand = " + wb.brand);
} }
What is the output of the program?
Anonymous Quiz
16%
Line 6 generates a compiler error
5%
Line 7 generates a compiler error
14%
There is no output
47%
Empty = false, Brand = null
6%
Empty = false, Brand =
12%
Empty = null, Brand = null
Code snippet
package aquarium; public class Water { }
package aquarium;
import java.lang.*;
import java.lang.System;
import aquarium.Water;
import aquarium.*;
public class Tank {
public void print(Water water) {
System.out.println(water); } }
Given the classes above, what is the maximum number of imports that can be removed and have the code still compile?
Anonymous Quiz
10%
0
9%
1
18%
2
20%
3
16%
4
27%
Does not compile
Which of the following are valid Java identifiers?
Anonymous Poll
35%
A$B
47%
_helloWorld
20%
true
26%
java.lang
44%
Public
10%
1980_s
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
5%
java BirdDisplay Sparrow Blue Jay
32%
java BirdDisplay Sparrow "Blue Jay"
7%
java BirdDisplay Blue Jay Sparrow
13%
java BirdDisplay "Blue Jay" Sparrow
6%
java BirdDisplay.class Sparrow "Blue Jay"
3%
java BirdDisplay.class "Blue Jay" Sparrow
33%
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 above output?
Anonymous Quiz
29%
0
35%
4
15%
Compilation fails on line 3
13%
Compilation fails on line 4
3%
Compilation fails on line 7
5%
Compilation fails on line 8
Code snippet:
1: public class Fish {
2: public static void main(String[] args) {
3: int numFish = 4;
4: String fishType = "tuna";
5: String anotherFish = numFish + 1;
6: System.out.println(anotherFish + " " + fishType);
7: System.out.println(numFish + " " + 1);
8: } }
What is output by the code above?
Anonymous Quiz
10%
4 1
5%
41
6%
5
21%
5 tuna
6%
5tuna
4%
51tuna
48%
The code does not compile
Code snippet:
3: String s = "Hello";
4: String t = new String(s);
5: if ("Hello".equals(s)) System.out.print("one ");
6: if (t == s) System.out.print("two ");
7: if (t.equals(s)) System.out.print("three ");
8: if ("Hello" == s) System.out.print("four ");
9: if ("Hello" == t) System.out.print("five");
Which of the following are output by this code?
Anonymous Quiz
14%
one
3%
two
8%
three
3%
four
3%
five
25%
one two three four five
7%
one two three
29%
one three four
5%
two four five
4%
two three four
Which of the following Java operators can be used with boolean variables?
Anonymous Poll
72%
==
9%
+
6%
--
61%
!
7%
%
26%
<=
Code snippet:
1: public class CompareValues {
2: public static void main(String[] args) {
3: int x = 0;
4: while(x++ < 10) {}
5: String message = x > 10 ? "Greater than" : false;
6: System.out.println(message+","+x);
7: }
8: }
What is the output of the application above?
Anonymous Quiz
11%
Greater than,10
17%
false,10
13%
Greater than,11
8%
false,11
16%
The code will not compile because of line 4
34%
The code will not compile because of line 5
Code snippet:
7: StringBuilder sb = new StringBuilder();
8: sb.append("aaa").insert(1, "bb").insert(4, "ccc");
9: System.out.println(sb);