Object Oriented Programings (Oops)
Object Oriented Programings (Oops)
PROGRAMINGS(OOPS)
*OOPS FEATURES
INTRODUCTION TO OBJECT ORIENTED
PROGRAMINGS(OOPS)
Definition:-
Object oriented programming is an approach to program
organization and development that attempts to eliminate
some of the pitfalls of conventional programming method by
incorporating the best of structured programming feature
with several powerful new concept
Working definition of opps as:-
“Object oriented programming is as an approach that
provide a way modular writing program by creating a
partition memory area for both the data and function
that can be used as templates for creating copy such
models on demand”
Features of object oriented programming languages:-
A B
Example of single inheritance:-
class Father{
void height()
{
System.out.println("\t Taller in height.");
}
}
class Son extends Father{
void body() {
System.out.println("\t Body is fat.");
}
}
public class SingleInheritance {
c
A B
Example of Multilevel inheritance:-
class GrandFather{
void Behaviour()
{
System.out.println("\t Good behaviour .");
}
}
class Father extends GrandFather{
void height()
{
System.out.println("\t Taller in height.");
}
}
class Son extends Father{
void body() {
System.out.println("\t Body is fat.");
}
}
public class MultilevelInheritance1 {
public static void main(String[] args) {
Son s = new Son();
System.out.println("\tPersonality of son:-"); OUTPUT:-
s.Behaviour();
s.height();
Personality of son:-
s.body(); Good behaviour .
} Taller in height.
Body is fat.
(iii).Hierarchical inheritance:-
when more than one subclass inheriting the property and features
of only one super class 10 that type of inheritance is known as
hierarchical inheritance
A
B C D
Example of Hierarchical inheritance:-
class Father2{
void height()
{
System.out.println("\t Taller in height.");
}
}
class Son2 extends Father2{
void body() {
System.out.println("\t Body is fat.");
}
}
class Doughter extends Father2{
void body() {
System.out.println("\t Body is slim.");
}
}
public class Hierarchical_Inheritance {
public static void main(String[] args) {
Son2 s = new Son2();
System.out.println("\tPersonality of son:-"); OUTPUT:-
s.height();
s.body();
Personality of son:-
Doughter d = new Doughter(); Taller in height.
System.out.println("\tPersonality of Doughter:-"); Body is fat.
d.height();
d.body(); Personality of Doughter:-
} Taller in height.
}
Body is slim.
(iv).Multiple inheritance:-
when one subclass having more than one super class and inherit all
features from all parent class then that type of inheritance is known as
multiple inheritance.
But to reduce the complexity and simplicity of the language multiple
inheritance is not supported in Java and achieved by interface
A B
C
(v).Hybrid inheritance:-
hybrid inheritance is a mix of two or more of the above type of
inheritances. It is also not supported and achieved by interface only.
A B C
X Y
5.Polymorphism :-
Polymorphism is a Greek term means the ability to take
more than one form.
That property by which we can send the same message to
the object of several different class and each object can
respond in a different way depending on its class is known as
polymorphism.
Through polymorphism we can send such a message without
knowing to which of class the object belongs.