1.

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.


Discussion

No Comment Found

Related InterviewSolutions