Professional Documents
Culture Documents
IN JAVA
Object-Oriented Programming
www.beginwithjava.com
What Is Inheritance?
Calling the Superclass Constructor
Overriding Methods
Protected Member
Multilevel Inheritance
Polymorphism
Abstract Classes and Abstract Method
Interfaces
www.beginwithjava.com
WHAT IS INHERITANCE
Inheritance is the mechanism that allows
programmers to create new classes from existing
class. By using inheritance programmers can re-use
code they've already written.
Any new class that you create from an existing
class is called sub class; existing class is
called super class.
www.beginwithjava.com
www.beginwithjava.com
The sub class gets all of the methods and state variables of the super
class by default.
The sub class can add new methods and state variables.
www.beginwithjava.com
www.beginwithjava.com
PROTECTED MEMBER
Class
Y
Y
Y
www.beginwithjava.com
Subclass
Y
Y
N
World
Y
N
N
continue.
Visit www.beginwithjava.com