in Education by
Which of these is an correct way of defining generic method? (a) name(T1, T2, …, Tn) { /* … */ } (b) public name { /* … */ } (c) class name[T1, T2, …, Tn] { /* … */ } (d) name{T1, T2, …, Tn} { /* … */ } I have been asked this question in an internship interview. The question is from Generic Methods topic in portion Generics of Java Select the correct answer from above options JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
The correct option is (b) public name { /* … */ } The explanation is: The syntax for a generic method includes a type parameter, inside angle brackets, and appears before the method’s return type. For static generic methods, the type parameter section must appear before the method’s return type.

Related questions

0 votes
    Which of these is an correct way of defining generic class? (a) class name(T1, T2, , Tn) { ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 24, 2021 in Education by JackTerrance
0 votes
    Which of these type parameters is used for a generic methods to return and accept any type of object? ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 24, 2021 in Education by JackTerrance
0 votes
    Which of these types cannot be used to initiate a generic type? (a) Integer class (b) Float class ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 24, 2021 in Education by JackTerrance
0 votes
0 votes
    Which of the following is the correct way of implementing an interface A by class B? (a) class B ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 24, 2021 in Education by JackTerrance
0 votes
    What are generic methods? (a) Generic methods are the methods defined in a generic class (b) Generic ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 24, 2021 in Education by JackTerrance
0 votes
    Which of these method of Array class is used sort an array or its subset? (a) binarysort() (b) ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    Which of these interface declares core method that all collections will have? (a) set (b) EventListner (c ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 25, 2021 in Education by JackTerrance
...