Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 14

Inheritance

Objective
• Implement inheritance
• Develop code that demonstrates the use of polymorphism.
• Differentiate between the type of a reference and the type of an
object.
• Determine when casting is necessary.
• Use super and this to access objects and constructors.
• Use abstract classes and interfaces
Inheritance with classes
Inheritance with classes
Without Inheritance
With Inheritance
Which base class members are inherited by a
derived class?
• public—Members with public access are visible to all the other
classes.
• protected—Members with protected access are accessible to all the
derived classes, regardless of the packages in which the base and
derived classes are defined.
• Default—Members with default access can be accessed in a derived
class only if base and derived classes reside in the same package.
JAVA ACCESS MODIFIER
Which of the options is correct for this
modified code?

You might also like