Core Java MCQ of Java Full Stack Of Training Set-1

1).Emma is writing a program, where she needs to convert a collection to an arraylist Choose the correct option to help her. Option: a)ArrayList newList=srcCollection.stream().collect(toCollection(ArrayLists::new)); b)ArrayList<syn> newList= srcCollection.stream().collect(toCollection(ArrayList::new)); c)ArrayList <syn> newList =Collection.stream().collect(toCollection(ArrayList::new)); d)ArrayList <syn>newList= srcCollection.stream().collect (Collection(ArrayList::new)); Answer:-b 2) What will be the output of the following Java code? public class Main { public static void main(String[] … Read more