Java OCA OCP Practice Question 198

Question

Given:

public class Main {
  public static void main(String[] args) {
    char[] ca = {0x4e, \u004e, 78};
    System.out.println((ca[0] == ca[1]) + " " + (ca[0] == ca[2]));
  }
}

What is the result?

  • A. true true
  • B. true false
  • C. false true
  • D. false false
  • E. Compilation fails


E is correct.

Note

The Unicode declaration must be enclosed in single quotes: '\u004e'.

If this were done, the answer would be A.




PreviousNext

Related