OCA Java SE 8 Core Java APIs - OCA Mock Question Core Java APIs 4-4








Question

What is the result of the following code?

     StringBuilder b = "ABCDEF"; 
     b.append(4).deleteCharAt(3).delete(3, b.length() - 1); 
     System.out.println(b); 
  1. ABC
  2. ABC4
  3. ABCD4
  4. ABCDE4
  5. An exception is thrown.
  6. The code does not compile.




Answer



F.

Note

The first line does not compile because you cannot assign a String to a StringBuilder.