Generics


  1. Which of these types cannot be used to initiate a generic type?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    Primitive Types


  1. Which of these instance cannot be created?











  1. 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.



  1. Which of these data type cannot be type parameterized?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Array


  1. What is the output of this program?
    import java.util.*;
    public class Result
    {
    public static double sumOfList(List list)
    {
    double var = 0.0;
    for (Number num : list)
    var += num.doubleValue();
    return var;
    }
    public static void main(String args[])
    {
    List obj = Arrays.asList(4.3, 5.6, 7.8);
    System.out.println(sumOfList(obj));
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    17.7



  1. Which of these is wildcard symbol?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    In generic code, the question mark (?), called the wildcard, represents an unknown type.