Java - Interview Questions and Answers for 'Generics' | Search Java Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com
Share

Search Java Interview Questions


 2098 questions in repository.
 There are more than 200 unanswered questions.
Click here and help us by providing the answer.
Label / Company      Label / Company / Text

   



Interview Questions and Answers for 'Generics' - 8 question(s) found - Order By Newest

 Q1. What are concepts introduced with Java 5 ?Core Java
Anonymous
Ans. Generics , Enums , Autoboxing , Annotations and Static Import.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   java5   generics   enum   autoboxing   annotations   static import        rare

Try 1 Question(s) Test


 Q2. Is this a valid initialization ? Explain.

Collection<Collection> collection = new LinkedList<LinkedList>();
Core Java2017-07-23 18:25:34

Ans. No. It will result in a type mismatch error.

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 :   

   Like      Discuss      Correct / Improve     generics  type argument


 Q3. Is it legal to initialize List like this ?


LinkedList l=new LinkedList();
Admin
info@buggybread.com
Ans. No, Generic parameters cannot be primitives.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   collections   list   linkedlist   generics   yes-no


 Q4. Which of the following syntax is correct ?

import static java.lang.System.*;

or

static import java.lang.System.*;
Core Java
Admin
info@buggybread.com
Ans. import static java.lang.System.*;

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   static import   generics   import


 Q5. Which of the following syntax are correct ?

a. LinkedList l=new LinkedList();
b. List l=new LinkedList();
c. LinkedList l=new LinkedList();
d. List l = new LinkedList();
Core Java
Admin
info@buggybread.com
Ans. c and d are correct.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   generics   linkedlist   list   collections      basic


Usually asked with Questions related to Generics.
 Q6. What are Type Erasures in Java ?Core Java2016-11-15 09:59:21

Ans. Type erasure applies to the use of generics. When generics are used, they're pre compiled into compile time checks and execution-time casts.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     type erasures  generics     OpenCrowd  Nexient      intermediate        rare


 Q7. Explain Generics in Java ?Core Java2017-08-01 12:00:02

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 :   

   Like      Discuss      Correct / Improve     generics     TIAA.Cognizant (CTS)  HCL Technologies  Infosys Technologies  Accenture


 Q8. In case of generic class declared like following , What can T hold

class MyClass<T>{
T element;
}
Core Java2017-08-10 17:05:10

 This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     generics




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



comments powered by Disqus
 

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked:
         

X Close this

X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: