Home / Java Programming / Java.lang Class :: Discussion

Discussion :: Java.lang Class

  1. What will be the output of the program?

    String d = "bookkeeper"; d.substring(1,7); d = "w" + d; d.append("woo");  /* Line 4 */ System.out.println(d); 

  2. A.
    wookkeewoo
    B.
    wbookkeeper
    C.
    wbookkeewoo
    D.
    Compilation fails.

    View Answer

    Workspace

    Answer : Option D

    Explanation :

    In line 4 the code calls a StringBuffer method, append() on a String object.


Be The First To Comment