Class in Java

Collection of objects is called class, It is a Logical Entity.

A Class can also be defined as a blueprint from which you can create an individual object.

Class doesn’t consume any Space.

A Class is a group of objects which have common properties. It is a template or Blueprint from which objects are created.

It is a Logical Entity ,It can’t be Physical

Class Name should be start from Uppercase letter and should be a Noun

A Class in java can Contains :-

  • Fields
  • methods
  • constructor
  • Blocks
  • Nested Class and Interface

Instance Variable in Java :-

A Variable which is created inside a class but outside the method is known as an instance variable.

Instance variable doesn’t get memory at compile time.

It gets memory at runtime when an object or instance is created. That is why it is known as instance variable.

Method in Java :-

In java , a method is like a function which is used to expose the behaviour of an Object.

Advantage Of Method:-

Code Reusability

Code Optimization