Sail E0 Webinar

MCQs

Total Questions : 10
Question 1. Which of these type parameters is used for a generic class to return and accept a number?
  1.    K
  2.    N
  3.    T
  4.    V
 Discuss Question
Answer: Option B. -> N




Question 2. Which of the following is Faster, StringBuilder or StringBuffer?
  1.    StringBuilder
  2.    StringBuffer
  3.    Both of the above
  4.    None of the above
 Discuss Question
Answer: Option A. -> StringBuilder




Question 3. Which of the following allows us to call generic methods as a normal method?
  1.    Type Interface
  2.    Interface
  3.    Inner class
  4.    All of the mentioned
 Discuss Question
Answer: Option A. -> Type Interface




Question 4. Which of the following is incorrect statement regarding the use of generics and parameterized types in Java?
  1.    Generics provide type safety by shifting more type checking responsibilities to the compiler
  2.    Generics and parameterized types eliminate the need for down casts when using Java Collections
  3.    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
  4.    All of the mentioned
 Discuss Question
Answer: Option 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




Question 5. Why are generics used?
  1.    Generics make code more fast
  2.    Generics make code more optimised and readable
  3.    Generics add stability to your code by making more of your bugs detectable at compile time
  4.    Generics add stability to your code by making more of your bugs detectable at a runtime
 Discuss Question
Answer: Option C. -> Generics add stability to your code by making more of your bugs detectable at compile time




Question 6. Which of the following reference types cannot be generic?
  1.    Anonymous inner class
  2.    Interface
  3.    Inner class
  4.    All of the mentioned
 Discuss Question
Answer: Option A. -> Anonymous inner class




Question 7. Which of these types cannot be used to initiate a generic type?
  1.    Integer class
  2.    Float Class
  3.    Primitive Types
  4.    Collections
 Discuss Question
Answer: Option C. -> Primitive Types




Question 8. What is the default value of byte variable?
  1.    0
  2.    0.5
  3.    null
  4.    undefined
 Discuss Question
Answer: Option A. -> 0




Question 9. Which of these is a correct way of defining of a generic method?
  1.    name(T1, T2, "¦, Tn) { /* "¦ */ }
  2.    public name { /* "¦ */ }
  3.    class name[T1, T2, "¦, Tn] { /* "¦ */ }
  4.    name{T1, T2, "¦, Tn} { /* "¦ */ }
 Discuss Question
Answer: Option C. -> class name[T1, T2, "¦, Tn] { /* "¦ */ }




Question 10. Which of these instances cannot be created?
  1.    Integer Instance
  2.    Generic Class Instance
  3.    Generic Type Instance
  4.    Collection Instances
 Discuss Question
Answer: Option C. -> Generic Type Instance




Latest Videos

Latest Test Papers