Telegram Web Link
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 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);
} }
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]);
} }
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: } }
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: } }
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 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: }
Code snippet:
7: StringBuilder sb = new StringBuilder();
8: sb.append("aaa").insert(1, "bb").insert(4, "ccc");
9: System.out.println(sb);
2025/07/05 14:44:08
Back to Top
HTML Embed Code: