Java – OOP Features

Introduction to Object oriented programming:

  • Java is Object Oriented Programming language.
  • OOPs is the concept of defining objects and establish communication between them.
  • The Main principles of Object-Oriented Programming are,
  • Encapsulation
  • Inheritance
  • Abstraction
  • Polymorphism

Note: We implement Object-Oriented functionality using Classes and Objects

Class: Class contains variables and methods. Java application is a collection of classes

SyntaxExample
class ClassName
{
            Variables ;
               &
            Methods ;
}
class Account
{
            long num;
            String name;
            double balance;
            void withdraw(){
               logic;
            }
            void deposit(){
               logic;
            }
}

Object: Object is an instance of class.Instance (non static) variables of class get memory inside the Object.

Syntax:  ClassName  reference = new ClassName();

Example:  Account  acc = new Account();

Note: Class is a Model from which we can define multiple objects of same type

Scroll to Top