Home / CSE MCQs / Java Generics ::

CSE MCQs :: Java Generics

  1. Which of these type parameters is used for a generic class to return and accept a number?
  2. A.
    K
    B.
    N
    C.
    T
    D.
    V

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. Which of the following is incorrect statement regarding the use of generics and parameterized types in Java?
  4. A.
    Generics provide type safety by shifting more type checking responsibilities to the compiler
    B.
    Generics and parameterized types eliminate the need for down casts when using Java Collections
    C.
    When designing your own collections class (say, a linked list), generics and parameterized types allow you to achieve type safety with just a single class definition as opposed to defining multiple classes
    D.
    All of the mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. Which of the following allows us to call generic methods as a normal method?
  6. A.
    Type Interface
    B.
    Interface
    C.
    Inner class
    D.
    All of the mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. Why are generics used?
  8. A.
    Generics make code more fast
    B.
    Generics make code more optimised and readable
    C.
    Generics add stability to your code by making more of your bugs detectable at compile time
    D.
    Generics add stability to your code by making more of your bugs detectable at a runtime

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. Which of the following is Faster, StringBuilder or StringBuffer?
  10. A.
    StringBuilder
    B.
    StringBuffer
    C.
    Both of the above
    D.
    None of the above

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. Which of the following reference types cannot be generic?
  12. A.
    Anonymous inner class
    B.
    Interface
    C.
    Inner class
    D.
    All of the mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. Which of these types cannot be used to initiate a generic type?
  14. A.
    Integer class
    B.
    Float Class
    C.
    Primitive Types
    D.
    Collections

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. Which of these instances cannot be created?
  16. A.
    Integer Instance
    B.
    Generic Class Instance
    C.
    Generic Type Instance
    D.
    Collection Instances

    View Answer

    Workspace

    Discuss Discuss in Forum