Programming - Generic Types
You Are Here :: Home > JAVA > Generic Types - General Questions
1. |
A ___________ class represents a class that is type-safe
|
A. |
generic |
B.
|
non generic |
C.
|
both
|
D.
|
none
|
|
Answer: Option A
Explanation:
A generic class can act upon any datatype.so a generic class represents a class that is type-safe |
|
2. |
Generic classes and generic interface are also known as __________
|
A. |
parameterized types |
B.
|
non parameterized types |
C.
|
both
|
D.
|
none
|
|
Answer: Option A
Explanation:
Because they use a parameter that determines what datatype they should work upon. |
|
3. |
Is the programmer need to rewrite the class or interface,when a generic class or generic interfaces is written?
|
A. |
Yes |
B.
|
no |
C.
|
Cant say
|
D.
|
none
|
|
Answer: Option B
Explanation:
No need to rewrite the code for the same class or interface because whenever user wants to use the class or interface with a new datatype. |
|
4. |
Generic type cannot work with _______________ datatypes
|
A. |
non primitive |
B.
|
primitive |
C.
|
both
|
D.
|
none
|
|
Answer: Option B
Explanation:
Generic types are designed to act upon objects.so it cannot work with primitive datatypes. |
|
5. |
class Myclass
{
class code;
}
here is called as __________________________
|
A. |
class |
B.
|
method |
C.
|
Generic parameter
|
D.
|
all the above
|
|
Answer: Option C
Explanation:
Generic parameters determines at the time of compilation. |
|
6. |
Creating non-generic version of a generic type by the java compiler is called ________
|
A. |
object |
B.
|
class |
C.
|
Methods
|
D.
|
erasure
|
|
Answer: Option D
Explanation:
Erasure is defined as creating non-generic version of a generic type by the java compiler. |
|
next »