Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
27 views

2.java OOP Concepts

This document discusses core concepts of object-oriented programming in Java including class, object, encapsulation, abstraction, inheritance, and polymorphism. It defines class as a blueprint for creating objects with member data and methods. An object is an instance of a class with a state and behavior. Encapsulation combines data and methods into a single unit, while abstraction hides internal details and only shows essential functionality. Inheritance allows a child class to acquire properties from a parent class. Polymorphism means an entity can perform different operations depending on the scenario.

Uploaded by

srocky4life
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

2.java OOP Concepts

This document discusses core concepts of object-oriented programming in Java including class, object, encapsulation, abstraction, inheritance, and polymorphism. It defines class as a blueprint for creating objects with member data and methods. An object is an instance of a class with a state and behavior. Encapsulation combines data and methods into a single unit, while abstraction hides internal details and only shows essential functionality. Inheritance allows a child class to acquire properties from a parent class. Polymorphism means an entity can perform different operations depending on the scenario.

Uploaded by

srocky4life
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

JAVA Programming Language

OOPs Concepts
Concepts of Object Oriented Programming:

• Class
• Object
• Data abstraction
• Data hiding
• Encapsulation
• Inheritance
• Polymorphism
•  Encapsulation, Abstraction, Inheritance and polymorphism are the
core concepts of OOP.,if any programming language follows these
concepts we can say it as Object Oriented Program.
Class & Objects
• Class
• In Java, class is a user defined datatype/pre defined data type type which
has its own member data and member methods.
• A blue print/template to create objects
• Ex: Car, Student ,Animal..etc.

• Objects
• Object is a Instance of class
• Anything which has a state(data) and behavior(function),we can say its an
object.
• Ex: Ford, Arun, dog.
Class & Objects
• Class
• In Java, class is a user defined data type which has its own member data
and member methods.
• A blue print/template to create objects
• Ex: Car, Student ,Animal..etc.

• Objects
• Object is a Instance of class
• Anything which has a state(data) and behavior(function),we can say its an
object.
• Ex: Ford, Arun, dog.
Example 3: Class and Object
• Class Stundent
• Object ajay
o Member data regno,name,phy,che,bio,math,total,avg
o Member methods  get(),calculate(),display()

o We can create any no of objects for a class.


Data abstraction

• Abstraction is hiding the internal details and showing only essential


functionality. In the abstraction concept, we do not show the actual
implementation to the end user, instead we provide only essential
things.
• For example, if we want to drive a car, we does not need to know about
the internal functionality like how wheel system works? how brake
system works? how music system works? etc.
• For example, By using ATM GUI screen user accessing set of services
what the bank is offering without knowing internal implementation .
Data hiding

• Data Hiding in Java is hiding the variables(data) of a class from other


classes. It can only be accessed through the method of their current
class.
• In java,Data hiding is achieved using Access modifier
Example4: Data hiding
class Sample
{
public int a;
private int b;
void display()
{
System.out.println("No1 = "+a+"No2 = "+b);
}
}
public class Main
{
public static void main(String[] args)
{
Sample s=new Sample();
s.a=10;
s.b=20;
s.display();
}
}
Encapsulation

• Encapsulation is the process of combining data and method into a


single unit (object / class)
• The java programming language uses the class concept to implement
encapsulation.
• So, Using the object of the class only, we can access the member data
and functions of the class.
Inheritance

• Inheritance is the process of acquiring properties and behaviors from one


object to another object or one class to another class.
• In inheritance, we derive a new class from the existing class. Here, the
new class acquires the properties and behaviors from the existing class.
• In the inheritance concept, the class which provides properties is called
as parent class and the class which receives the properties is called as
child class
• In Java, the parent class is called super class and child class is called sub
class.
• The Main purpose of Inheritance is Code reusability.
Inheritance

• We achieve code reusability using Inheritance


Polymorphism

• The word polymorphism means having many forms.


• Real life example of polymorphism: A person at the same time can have
different characteristic. Like a man at the same time is a father, a husband, an
employee. So the same person posses different behavior in different situations.
This is called polymorphism.
• That is, the same entity (method or operator or object) can perform different
operations in different scenarios.
• For example :
• 3+4 7
• “SMART”+“Training”+"Resources”  SMART Training Resources
The operator ‘+’ does addition as well as string concatenation.
Thank you

You might also like