
The answer of OOP Final Exam 2nd – MCs RADHWAN
1
Q1 answer any two of following:
a. What is this in java?
There can be a lot of usage of java this keyword. In java, this is a reference variable that
refers to the current object.
b. What is polymorphism in java?
Polymorphism in java is a concept by which we can perform a single action by different
ways
c. Why use Java encapsulation?
Encapsulation in java is a process of wrapping code and data together into a single unit,
For example capsule i.e. mixed of several medicines.
Q2 what is an inheritance and which types are supported in java? Explain that with a source
code example.
Solution:-
Inheritance in java is a mechanism in which one object acquires all the properties and behaviors
of parent object.
The idea behind inheritance in java is that you can create new classes that are built upon existing
classes. When you inherit from an existing class, you can reuse methods and fields of parent
class, and you can add new methods and fields also.
There can be three types of inheritance in java: single, multilevel and hierarchical.