Explanation: Any method declared void doesn't return a value. It does not need to contain a return statement, but it may do so. In such a case, a return statement can be used to branch out of a control flow block and exit the method and is simply used like this:return;
Question : You have been given below 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()); } }
When you run it, what would be result ?
1. class java.lang.String class java.lang.String class java.util.ArrayList 2. class java.lang.Object class java.lang. Object class java.util.Collection 3. Access Mostly Uused Products by 50000+ Subscribers 4. class java.lang.StringBuilder class java.lang.String class java.util.List