Java Programming/Inheritance

Syntax
In Java, the syntax for deriving a child class from a parent class is:

Example
Here is a program that uses a class Video to represent movies available at a video rental store. The Video class has basic information in it, and would be OK for documentaries and instructional tapes. But movies need more information. An additional class, Movie, is created that is similar to Video, but has the name of the director and a rating.

The class Movie is a derived class (subclass) of Video. An object of type Movie has the following members in it:

Both classes are defined: the Video class can be used to construct objects of that type, and now the Movie class can be used to construct objects of the Movie type.

The class definition for Video has a constructor that initializes the member data of Video objects. The class Movie has a constructor that initializes the data of Movie objects. The constructor for class Movie looks like this:

The statement super(title, len) invokes the base class' constructor to initialize some of the data. Then the next two statements (on one line) initialize the members that only Movie has. When super is used in this way, it must be the first statement in the subclass' constructor.

4. It is not necessary to use super; the following would also work as a constructor for Movie:

In this constructor, each variable of the newly created Movie object is set to an initial value.