What should be inserted in the code given below at line marked //10:
class MyClass{
}
class MyComparable implements Comparable<MyClass>{
public int compareTo( *INSERT CODE HERE* x ){ //10
return 0;
}
}
here in interface<My Class> had mentioned, i have not found it in the book i was preparing from,
can you explain this problem in detail?
what i mean can you give one more example like this are questions related to this type of questions
as i was not sure with the explanation given in mock why answer is not "Object" but "MyClass"?
Well, it is a rule of Java language. If you type a generic interface to a particular type such as the case here (Comparable is being typed to MyClass), you have to use the same type while implementing methods of that interface.