Return to site
JAVA CERTIFICATION QUESTION: Initializing standard and final variables in Java
·
👉 Generally, every field in an object or class is initialized to a zero-like value during the allocation of memory—but not always.
Given the SuperChar class:
public class SuperChar { static final char zero; // line n2 private transient final char one = '1'; // line n3 public SuperChar() { System.out.print("'" + zero + one + "'"); } public static void main(String... args) { new SuperChar(); } }
If the numeric value of the char '1' is 49, what is the result? Choose one.
A. ' 1'
B. '01'
C. '1'
D. ' 49'
E. '49'
F. Compilation fails due to line n2.
G. Compilation fails due to line n3.