Topic 3 : Introduction to
› Method Overriding
› final Keyword
› Abstract class and methods
4 major principles of OOP
› Encapsulation is the hiding of data implementation by restricting access
to accessors and mutators (getters and setters).
› Concept of encapsulation is creating the class with private attributes and
public methods to interact those attributes.
› Derived from two Greek words : poly which means many and
morphs, which means form.
› So, the meaning of the word polymorphism is many forms.
› Two types
1. Static polymorphism or early binding or compile-time polymorphism
2. Dynamic polymorphism or late binding or runtime polymorphism
› Static polymorphism is obtained through method overloading.
› Write examples of method overloading and constructor
› The feature by which one class acquires the characteristics of an
existing class is known as Inheritance.
› A class that is inherited is called super class or parent class.
› A class that inherits the superclass is called a sub class or child
› The extends keyword is used in sub class to inherit a super
› A class can extend from only one parent.
› Do you remember the previous example of ParentClass and
› Did you notice a display() method in ParentClass and also in
› The display() method in ChildClass overwrites definition of
display() method of ParentClass.
› This is known as Method Overriding.
The final keyword
› Purposes of final keyword in Java
1. Declaring a constant variable
2. Preventing a method from being overridden
3. Preventing a class from being inherited.
Abstract Methods & Classes
› A method without a definition is known as abstract method.
› A method is declared abstract when it needs to be overridden in its
› An abstract class is a class that has at least one abstract method.
› Java allows us to define abstract methods and classes by using the
› An abstract class cannot be instantiated i.e. you cannot
create objects of an abstract class.
› An interface is a collection of various methods without definition.
› An interface is declared using interface keyword instead of class.
› An interface can be implemented by one or more class using the
› An advantage of using interfaces is that we can implement multiple
› An interface cannot be instantiated i.e. you cannot create
objects of an interface.
› All the methods declared in the interface must be overridden.
DDOOCP Practice Questions
› Describe the structure of the syntax of a Java statement that
instances an object.
› Explain the terms encapsulation and polymorphism with reference
to natural and manufactured real universe objects.
› Describe, giving examples in Java, the purpose of the extends
› Explain why the facility of inheritance, in the Java programming
language, is regarded as being so very important.
› Describe why the Object-Oriented paradigm is considered
superior to the Structured Programming paradigm.