aspose file tools
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


Win a copy of Groovy Fundamentals video training course this week in the Groovy forum!
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
Author

perfect example for abstract class

sanjana suman
Ranch Hand

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

{

public abstract void play();

}

(or)

abstract class Click

{

public void play(){}

}

please any one tell me what is perfect abstract class.


thanks in advance,
sanjana suman.
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2887
    
    9

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
Muhammad Khojaye
Ranch Hand

Joined: Apr 12, 2009
Posts: 449

http://www.coderanch.com/t/440945/Java-General-beginner/java/diff-b-w-abstract-class#1962569


Hope it helps


http://muhammadkhojaye.blogspot.com/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: perfect example for abstract class