File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Certification » Associate Certification (SCJA,OCAJ 5/6)
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: 1966
    
    7

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/OCM-JD OCPJP7
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
 
Similar Threads
Can we mark an overriding method as abstract
which method is implemented?
regarding class definition
need packages help
Overriding a method with an abstract version