+ 3

friends can you help me with this question?

Drag and drop from the options below to define a generic class, which has a member method that returns the value of x. Temp { T x; public Func() { x; } } static <x> return x class <T> T

18th Sep 2017, 12:38 PM
Sahil Bhat
Sahil Bhat - avatar
4 ответов
+ 5
Anser: class Temp<T> { T x; public T Func() { return x; } }
10th Jan 2020, 7:46 AM
Đào Ngọc Tuấn Anh
Đào Ngọc Tuấn Anh - avatar
+ 2
class<T> //start with "class" and make it generic <T> { T x: //define a variable "x" of type T (at this time we don't know the type yet, so we say T public T Func() //this method returns a value of type T { return x; //it returns the variable x that we have declared } //end of method }// end of class static is there to confuse you, it is not needed <x> is also there to confuse you, it not needed }
18th Sep 2017, 7:23 PM
sneeze
sneeze - avatar
0
I think that is answer of that question of define a generic class, which has a member method that returns the value of x. Class Temp <T> //generic <T> class { T x; public T Func(){ //generic T method return x; //return the variable x } }
1st Mar 2018, 7:41 PM
Esad Međedović
Esad Međedović - avatar
0
Drag and drop from the options below to initialize members in the constructor initializer list, and then print them out in the constructor body:
20th Apr 2020, 2:30 AM
Magesh .s
Magesh .s - avatar