Abstract Class, Abstract Method
abstract class Player {
abstract void play(int pos);
abstract void stop();
}Player p = new Player();//errorclass AudioPlayer extends Player {
void play(int pos) {} // implement abstract method
void stop() {}
}
//by implementing object, do not use abstract in front of child of Player
AudioPlayer ap = new AudioPlayer();//OK.
//add abstract because one is implemented and another is not.
abstract class AbstractPlayer extends Player {
void play(int pos)
//abstract void stop();
}
Last updated