• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

perfect example for abstract class

 
sanjana suman
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3404
13
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic