File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Associate Certification (SCJA,OCAJ 5/6) 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

Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Associate Certification (SCJA,OCAJ 5/6)
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: 2615

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.

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