InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Which of these is an correct way making a list that is upper bounded by class Number?(a) List |
|
Answer» RIGHT ANSWER is (a) List extends Number> Explanation: NONE. |
|
| 2. |
Which of these keywords is used to upper bound a wildcard?(a) stop(b) bound(c) extends(d) implementsThe question was asked in an online interview.I'm obligated to ask this question of Wildcards topic in chapter Generics of Java |
|
Answer» CORRECT OPTION is (C) extends The BEST I can explain: None. |
|
| 3. |
Which of these types cannot be used to initiate a generic type?(a) Integer class(b) Float class(c) Primitive Types(d) CollectionsI have been asked this question during an internship interview.The doubt is from Restrictions on Generics topic in section Generics of Java |
|
Answer» RIGHT option is (c) Primitive Types Best EXPLANATION: NONE. |
|
| 4. |
Which of these instance cannot be created?(a) Integer instance(b) Generic class instance(c) Generic type instance(d) Collection instancesI had been asked this question in exam.I'm obligated to ask this question of Restrictions on Generics in section Generics of Java |
|
Answer» Right choice is (c) GENERIC type instance |
|
| 5. |
What is use of wildcards?(a) It is used in cases when type being operated upon is not known(b) It is used to make code more readable(c) It is used to access members of super class(d) It is used for type argument of generic methodThis question was addressed to me in final exam.This intriguing question originated from Wildcards topic in portion Generics of Java |
|
Answer» RIGHT answer is (a) It is used in cases when type being operated upon is not known Easy EXPLANATION: The wildcard can be used in a variety of situations: as the type of a parameter, field, or local variable; sometimes as a return type (though it is better PROGRAMMING practice to be more specific). The wildcard is never used as a type argument for a generic method invocation, a generic class instance creation, or a SUPERTYPE. |
|
| 6. |
Which of these is an correct way of defining generic method?(a) name(T1, T2, …, Tn) { /* … */ }(b) public name { /* … */ }(c) class name[T1, T2, …, Tn] { /* … */ }(d) name{T1, T2, …, Tn} { /* … */ }I have been asked this question in an internship interview.The question is from Generic Methods topic in portion Generics of Java |
|
Answer» The correct option is (b) public |
|
| 7. |
Which of these is wildcard symbol?(a) ?(b) !(c) %(d) &I have been asked this question in an interview for internship.This question is from Wildcards in section Generics of Java |
|
Answer» The correct choice is (a) ? |
|
| 8. |
Which of these type parameters is used for a generic methods to return and accept any type of object?(a) K(b) N(c) T(d) VThis question was posed to me during an interview for a job.I'd like to ask this question from Generic Methods topic in chapter Generics of Java |
|
Answer» Right option is (C) T |
|
| 9. |
Which of these type parameters is used for a generic methods to return and accept a number?(a) K(b) N(c) T(d) VThe question was asked in an interview for job.I'm obligated to ask this question of Generic Methods in portion Generics of Java |
| Answer» | |
| 10. |
Which of these Exception handlers cannot be type parameterized?(a) catch(b) throw(c) throws(d) all of the mentionedThis question was posed to me by my school teacher while I was bunking the class.I want to ask this question from Generics topic in section Generics of Java |
|
Answer» RIGHT choice is (d) all of the mentioned The explanation is: we cannot Create, Catch, or THROW Objects of Parameterized TYPES as generic class cannot extend the Throwable class directly or indirectly. |
|
| 11. |
What are generic methods?(a) Generic methods are the methods defined in a generic class(b) Generic methods are the methods that extend generic class methods(c) Generic methods are methods that introduce their own type parameters(d) Generic methods are methods that take void parametersI got this question in exam.I'd like to ask this question from Generic Methods topic in division Generics of Java |
|
Answer» Correct choice is (c) GENERIC methods are methods that introduce their own TYPE parameters |
|