Java OCA OCP Practice Question 195

Question

Given:

public class Main {
  public static void main(String[] args) {
    StringBuilder sb = new StringBuilder("abc");
    String s = "abc";
    sb.reverse().append("d");
    s.toUpperCase().concat("d");
    System.out.println("." + sb + ". ." + s + ".");
  }
}

Which two substrings will be included in the result? (Choose two.)

A.  .abc.
B.  .ABCd.
C.  .ABCD.
D.  .cbad.
E.  .dcba.


A and D are correct.

Note

The String operations are working on a new (lost) String not String s.

The StringBuilder operations work from left to right.




PreviousNext

Related