enthuware.ocajp.i.v7.2.1367

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
ashishrai.kv
Posts: 33
Joined: Tue Jan 09, 2018 2:12 am
Contact:

enthuware.ocajp.i.v7.2.1367

Post by ashishrai.kv »

Code: Select all

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?

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: enthuware.ocajp.i.v7.2.1367

Post by admin »

Sorry, I am not able to understand your question. Can you be more clear about what exactly are you asking?
If you like our products and services, please help us by posting your review here.

ashishrai.kv
Posts: 33
Joined: Tue Jan 09, 2018 2:12 am
Contact:

Re: enthuware.ocajp.i.v7.2.1367

Post by ashishrai.kv »

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"?

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: enthuware.ocajp.i.v7.2.1367

Post by admin »

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.
If you like our products and services, please help us by posting your review here.

ashishrai.kv
Posts: 33
Joined: Tue Jan 09, 2018 2:12 am
Contact:

Re: enthuware.ocajp.i.v7.2.1367

Post by ashishrai.kv »

ok thank you.

Post Reply

Who is online

Users browsing this forum: No registered users and 79 guests