T4Tutorials .PK

Chapter 7 Generics MCQs

1. . Which of the following allows us to call generic methods as a normal method?

(A) Interface


(B) Type Interface


(C) Inner class


(D) All of the mentioned




2. . Which of these type parameters is used for a generic class to return and accept a number?

(A) N


(B) K


(C) T


(D) V




3. . Which of these type parameters is used for a generic method to return and accept any type of object?

(A) K


(B) T


(C) N


(D) V




4. . Which of the following is faster, StringBuilder or StringBuffer?

(A) Both of the above


(B) StringBuffer


(C) StringBuilder


(D) None of the above




5. . What are generic methods?

(A) Generic methods are the methods defined in a generic class


(B) Generic methods are methods that introduce their own type parameters


(C) Generic methods are the methods that extend generic class methods


(D) Generic methods are methods that take void parameters




6. . Which of the following cannot be type parameterized?

(A) Overloaded Methods


(B) Generic methods


(C) Class methods


(D) Overriding methods




7. . Which of these exception handlers cannot be type parameterized?

(A) catch


(B) all of the mentioned


(C) throws


(D) throw




8. . What is meant by the term generics?

(A) parameterized types


(B) class


(C) structure


(D) interface




9. . Are generics in C# the same as the generics in Java and templates in C++?

(A) Yes


(B) May be


(C) No


(D) None of the mentioned




10. . Choose the advantages of using generics?

(A) Generics facilitate type safety


(B) Generics facilitate improved performance and reduced code


(C) Generics promote the usage of parameterized types


(D) All of the mentioned




11. . Which of these is a correct way of defining a generic method?

(A) public name { / … / }


(B) name(T1, T2, …, Tn) { /* … / }


(C) class name[T1, T2, ..., Tn] { / … / }


(D) name{T1, T2, …, Tn} { / … */ }




12. . Which of the following types of reference cannot be generic?

(A) Inner classes


(B) Interface


(C) Inner class anonymous


(D) All the answers are true




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

(A) Integer class


(B) Float class


(C) Collections


(D) Primitive Types




14. . Which of this instance cannot be created?

(A) Generic type instance


(B) Generic class instance


(C) Integer instance


(D) Collection instances




Exit mobile version