Professional Documents
Culture Documents
Technologies (ICT)
Object Oriented Programming
● The main aim of OOP is to bind together the data and the functions that
operate on them so that no other part of the code can access this data
except that function.
Abstraction
Encapsulatio
n
Pillars
Inheritance
class Test{
public static void main(String[] args){
Student s=new Student(); //creating instance of the encapsulated class
s.setName("vijay"); //setting value in the name member
System.out.println(s.getName()); //getting value of the name member } }
Inheritance
Classes can have children; that is, one class can be created out of another
class. The capability of a class to derive properties and characteristics from
another class is called Inheritance.
• Subclass: The class that inherits the other class is known as subclass (also
known as derived or extended or child class). The subclass can add its
own fields and methods in addition to the superclass fields and methods.
• Reusability: We can derive our new class from the existing class. By
doing this, we are reusing the fields and methods of the existing class.
Type of Inheritance
class one {
public void print_geek()
{
System.out.println("Geeks");
}
}
Reusable, Easier to
OOP objects debug,
can be used classes often
across contain all
programs applicable
information
to them