A good answer might be:

  1. You should not have to write the same code more than once.
  2. To maintain consistency between related classes.

Music Video Class

So far the video rental application has two classes: VideoTape and Movie. Say that you wanted to create a new class, MusicVideo that will be like VideoTape but will have two new instance variables: artist (the name of the performer) and category ("R&B", "Pop", "Classical", "Other" ). Both of these will be Strings. The MusicVideo class will need its own constructor and its own show() method. Here is the base class:

class VideoTape
{
  String  title;    // name of the item
  int     length;   // number of minutes
  boolean avail;    // is the tape in the store?

  // constructor
  public VideoTape( String ttl, int lngth )
  {
    title = ttl; length = lngth; avail = true; 
  }

  public void show()
  {
    System.out.println( title + ", " + length + " min. available:" + avail );
  }
  
}

The new class will look something like this:

class ______________ extends _________________
{
  String  ______________;     //  the artist
  String  ______________;     //  the music category

  // constructor will go here (skip for now)
  
  // show method will go here (skip for now)

}  

QUESTION 14:

Write a definition of the class MusicVideo which extends the parent class Video. For now, leave out the constructor and the show() method.

Click Here after you have answered the question