Generics
- Which of these types cannot be used to initiate a generic type?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: B
Primitive Types
- Which of these instance cannot be created?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
It is not possible to create generic type instances. Example – “P obj = new P()” will give a compilation error.
- Which of these data type cannot be type parameterized?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Array
- What is the output of this program?
import java.util.*;
public class Result
{
public static double sumOfList(List extends Number> list)
{
double var = 0.0;
for (Number num : list)
var += num.doubleValue();
return var;
}
public static void main(String args[])
{
Listobj = Arrays.asList(4.3, 5.6, 7.8);
System.out.println(sumOfList(obj));
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
17.7
- Which of these is wildcard symbol?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
In generic code, the question mark (?), called the wildcard, represents an unknown type.