File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Anonymous class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Anonymous class" Watch "Anonymous class" New topic
Author

Anonymous class

Saibabaa Pragada
Ranch Hand

Joined: Oct 24, 2010
Posts: 162
Hi, This is from ExamLab. Please advice why I am getting this error at Line 9.
swaraj gupta
Ranch Hand

Joined: Oct 22, 2010
Posts: 181

Saibabaa Pragada wrote:Hi, This is from ExamLab. Please advice why I am getting this error at Line 9.


rb is Runnable(Supertype) type reference-variable and is referring to an instance of its anonymous subclass(Subtype), so using that reference it is not possible to invoke a method that does not exist in Runnable<interface>.

Note: When super class reference-variable is referring subclass instance then through that reference only those methods can be invoked that exists in both superclass and the subclass.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3054
    
  33

Can you please check the API for Runnable to see if it has start() method defined for it? You always use a Thread instance to start the thread.


Mohamed Sanaulla | My Blog
Imad Aydarooos
Ranch Hand

Joined: Nov 02, 2010
Posts: 87
You have to pass the Runnable type object to a Thread object, after that you have to invoke start() on the Thread object


love demgracy, knowledge demogracy, open source and Java - OCPJP 76%
Mark Guo
Ranch Hand

Joined: Nov 17, 2010
Posts: 58


This is the correct way to invoke start();

Regards!


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Anonymous class
 
Similar Threads
Threads
Thread question
Given: ...