File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Junior/Associate Certification (SCJA,OCAJ 5/6/8) and the fly likes perfect example for abstract class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Junior/Associate Certification (SCJA,OCAJ 5/6/8)
Bookmark "perfect example for abstract class" Watch "perfect example for abstract class" New topic

perfect example for abstract class

sanjana suman
Ranch Hand

Joined: Oct 09, 2008
Posts: 51
abstract class Click


public abstract void play();



abstract class Click


public void play(){}


please any one tell me what is perfect abstract class.

thanks in advance,
sanjana suman.
K. Tsang

Joined: Sep 13, 2007
Posts: 3132

Hello, first off your second class in fact IS TECHNICALLY NOT consider to be an abstract class because your play() method is 1) not abstract and 2) is a concrete method (has implementation).

Honestly, there isn't a "perfect" example. In your case, I would turn your first class into an interface. The second class would be a better example comparing the 2. Depending on what you do in your play() method. Subclasses can override the play() method accordingly.

K. Tsang JavaRanch SCJP5 SCJD OCPJP7 OCPWCD5 OCPBCD5 OCPWSD5 OCMJEA5 part 1 part 2/3
Muhammad Khojaye
Ranch Hand

Joined: Apr 12, 2009
Posts: 449

Hope it helps
I agree. Here's the link:
subject: perfect example for abstract class
It's not a secret anymore!