Java OCA OCP Practice Question 932

Question

Which of the following are legal?

Choose all that apply.

A.  List<String> theList = new Vector<String>; 
B.  List<String> theList = new Vector<String>(); 
C.  Vector <String> theVec = new Vector<String>; 
D.  Vector <String> theVec = new Vector<String>(); 


B, D.

Note

A and C are illegal, because a constructor call consists of a class name followed by parentheses.

B and D add the parentheses.

B assigns a Vector of Strings to a List of Strings, which is a legal assignment conversion.




PreviousNext

Related