Assessment Test

  1. What is the result of the following class? (Choose all that apply)
    1: public class _C {
    2:  private static int $;
    3:  public static void main(String[] main) {
    4:    String a_b;
    5:    System.out.print($);
    6:    System.out.print(a_b);
    7:  } }
    1. Compiler error on line 1.
    2. Compiler error on line 2.
    3. Compiler error on line 4.
    4. Compiler error on line 5.
    5. Compiler error on line 6.
    6. 0null
    7. nullnull
  2. What is the result of the following code?
    String s1 = "Java";
    String s2 = "Java";
    StringBuilder sb1 = new StringBuilder();
    sb1.append("Ja").append("va");
    System.out.println(s1 == s2);
    System.out.println(s1.equals(s2));
    System.out.println(sb1.toString() == s1);
    System.out.println(sb1.toString().equals(s1));
    1. true is printed out exactly once.
    2. true is printed ...

Get OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide: Exam 1Z0-808 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.