Select the correct answerWhich of these is an correct way of defining generic class?Optionsclass name[T1, T2, …, Tn] { /* … */ }class name<T1, T2, …, Tn> { /* … */ }class name(T1, T2, …, Tn) { /* … */ }class name{T1, T2, …, Tn} { /* … */ }
Question
Select the correct answerWhich of these is an correct way of defining generic class?Optionsclass name[T1, T2, …, Tn] { /* … / }class name<T1, T2, …, Tn> { / … / }class name(T1, T2, …, Tn) { / … / }class name{T1, T2, …, Tn} { / … */ }
Solution
The correct way of defining a generic class is:
class name<T1, T2, …, Tn> { /* … */ }
Similar Questions
the correct answerWhich of the following reference types cannot be generic?OptionsAnonymous inner classInner classInterfaceAll of the mentioned
What is the syntax for defining a generic class in Java?Select one:a. class <MyGen>b. class <MyGen>(T)c. class <MyGen>[<T>]d. class MyGen<T>
Which of the following is the correct 'syntax' to define the generic method m1() ?Group of answer choicespublic <K,U> int m1() {// K and U are used inside here}public <G> int m1(Double ob) {// G is used inside here}All are correctpublic <E> int m1(T ob) {// T is a class level type parameter}
Select the correct answerWhich of these type parameters is used for a generic class to return and accept any type of object?OptionsTNKV
Which of the following Java code snippets gives a compilation error?Group of answer choicesclass MyClass<T extends Number & Comparable<T>> { // ...}class MyClass<T extends String> { public void add(T item) { // ... }}class MyClass<T> { public void add(T item) { // ... }}class MyClass<T super Number> { // ...}
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.