OBJECT ORIENTED PROGRAMMING /OOPS CONCEPT IN JAVA

SAIROSHNI

OBJECT-ORIENTED:

  • To solve real-world problems using the concept of encapsulation, Data Hiding, inheritance polymorphism etc.
  • The idea is to contain data and function as a single unit. Such a unit is called an object
  • OOPS program and contains a number of objects.  the data of an object can be accessed by the function associated with the object.

  • OOP contains Six different classification:

      1. Class
      2. Object
      3. Inheritance
      4. polymorphism 
      5. Abstraction
      6. Encapsulation

oops concept in java
oops concept in java

CLASS

A class is a container which stores data and functions. It is common to all the objects of its types. class is userdefined data type.
It is a blueprint for creating objects. To create a class, use the keyword class.

Syntax:

public class main
{
int x=5;
}

OBJECTS

It is instance of a class. You can create multiple objects with same behaviour, instead of repeating code. A class can have multiple objects.

Syntax:

public class main
{ 
 int x=5;
public static void main(string[] arg)
{
 main myobj= new Main(); 
 System.out.println(myobj.x); 
}
}

INHERITANCE

 It is the process of creating a new class from existing class. Base class is parent class and child class is sub class. The basic advantages of inheritance are reusability of code, saves timing. The are different

Types of inheritance they are:

• Single inheritance
Multiple inheritance
Multilevel inheritance
Hierarchical inheritance
Hybrid inheritance 

POLYMORPHISM

polymorphism is defined as " one name many forms". There is no operator overloading in java ,java contains only function overloading.

TYPES OF POLYMORPHISM: 

  • Compile time polymorphism
  • Run-time polymorphism   

ABSTRACTION

Data abstraction it is an act of hiding implementational details from the outside world.

ENCAPSULATION

Wrapping up of data and functions in a single functional unit is called encapsulation.
Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send