You are on page 1of 1

Object

Objects have states and behaviors

Variable
Variable is name of reserved area allocated in memory

Types of Variable there are three types of variables in java:


1. local variable
2. instance variable
3. static variable

Local Variable:- A variable which is declared inside the method is called local variable.
Instance Variable:- A variable which is declared inside the class but outside the method, is called instance
variable . It is not declared as static.
Static variable:- A variable that is declared as static is called static variable. It cannot be local.

Here are the key differences between a constructor and a method:-


1. the constructor name is always the same the class name
2. the constructor has no return values but may take parameters
3. the constructor should perform initialization of the new object .
4. Unlike methods, constructors are not considered members of a class.

Rules for creating java constructor there are basically two rules defined for the constructor.
1. Constructor name must be same as its class name
2. Constructor must have no explicit return type
Types of java constructors there are two types of constructors:
1. Default constructor
2. Parameterized constructor
The main new concepts in OOP are:
1. encapsulation
2. polymorphism
3. inheritance

method overloading is an example of polymorphism. The general concept of polymorphism is “one interface,
multiple methods”.

You might also like