Java - Interview Questions and Answers on Generics

Q1.  What are concepts introduced with Java 5 ?

Ans. Generics , Enums , Autoboxing , Annotations and Static Import.

Q2.  Is it legal to initialize List like this ?

LinkedList<Integer> l=new LinkedList<int>(); 

Ans. No, Generic parameters cannot be primitives.

Q3.  Which of the following syntax is correct ?

import static java.lang.System.*;


static import java.lang.System.*;

Ans. import static java.lang.System.*;

Q4.  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. c and d are correct.

Subscribe to Java News and Posts. Get latest updates and posts on Java from
Enter your email address:
Delivered by FeedBurner
comments powered by Disqus