Given: What is the result?
A.
class java.lang.Object class java.lang.Object class java.util.Collection
B.
class java.lang.StringBuilder class java.lang.String class java.util.ArrayList
C.
class java.lang.String class java.lang.String class java.util.ArrayList
D.
class java.lang.StringBuilder class java.lang.String class java.util.List
B
B
Code:
import java.util.*;
public class Ref {
public static void main(String[] args) {
StringBuilder s1 = new StringBuilder(“Hello Java!”);
String s2 = s1.toString();
List lst = new ArrayList();
lst.add(s2);
System.out.println(s1.getClass());
System.out.println(s2.getClass());
System.out.println(lst.getClass());
}
}
Output:
class java.lang.StringBuilder
class java.lang.String
class java.util.ArrayList