1.

Which of these is an correct way of defining generic class?(a) class name(T1, T2, …, Tn) { /* … */ }(b) class name { /* … */ }(c) class name[T1, T2, …, Tn] { /* … */ }(d) class name{T1, T2, …, Tn} { /* … */ }This question was posed to me during an interview for a job.Asked question is from Type Interface in section Interfaces & Packages of Java

Answer»

The correct choice is (b) class name { /* … */ }

The BEST I can EXPLAIN: The type parameter SECTION, delimited by angle brackets (<>), FOLLOWS the class name. It specifies the type parameters (also called type variables) T1, T2, …, and Tn.



Discussion

No Comment Found

Related InterviewSolutions