More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know.
Collection<Collection> collection = new LinkedList<Collection>();
is a valid initialization as collection being reference of "Collection" class can hold object of derived Class "LinkedList" due to runtime Polymorphism. Runtime polymorphism is not applicable to type arguments.
Help us improve. Please let us know the company, where you were asked this question :
Q5. Which of the following syntax are correct ?a. LinkedList<Integer> l=new LinkedList<int>();b. List<Integer> l=new LinkedList<int>();c. LinkedList<Integer> l=new LinkedList<Integer>();d. List<Integer> l = new LinkedList<Integer>();
Ans. Generics are a facility of generic programming that were added to the Java programming language in 2004 within J2SE5.0. They allow "a type or method to operate on objects of various types while providing compile-time type safety.
Help us improve. Please let us know the company, where you were asked this question :