Which statement is true about primitive variables?
A. They can be compared with the == operator.
B. They can be compared with the equals method only.
C. They cannot be compared.
D. They can be compared with the compareTo method only.
Given the code fragment:
Which two code fragments are valid at line 2?
A. for (int count = 0; count < 5; count++) {
System.out.print(count);
}
B. package p1;
C. import java.util.*; public void display() { List
D. { private int num; }
E. private String name = "John"; public void display() { System.out.print(name); }
Given the code fragment:
Which code fragment, when inserted at line n1, enables the code to print Java Programming:1?
A. System.out.println(name + ":" + count);
B. System.out.println(c.name + ":" + count);
C. System.out.println(c.name + ":" + Course.count);
D. System.out.println(Course.name + ":" + c.count);
Given the code fragment:
What is the result?
A. 3
B. A compilation error occurs.
C. 2
D. 0
Given:
What is the result?
A. The code fails to compile. To make it compile, at line n1 insert: this () { }
B. The code fails to compile. To make it compile, at line n2 insert: this ();
C. The code fails to compile. To make it compile, at line n1 insert: Bus () { }
D. The code compiles and prints: default
luxury
Given the code fragment:
What is the result?
A. 10 20 10 15 20
B. A runtime exception is thrown.
C. 10 20 10 20
D. A compilation error occurs.
Which method identifier is correct according to Java naming conventions?
A. BillCalculator
B. calculateBill
C. calculatebill
D. Calculator
Which two components can class declarations include?
A. A list of instance methods
B. The main method
C. Interfaces implemented by the class
D. The public modifier