Object Oriented Programming Components

What is Class ?
1. Class is a blueprint or template of an Object.
2. Class is a group of objects which have same State and Behaviour.
3. Class is a container that contain following things:
- Data Type
- Method
- Constructor
- Block
Data Type
- Data Type in Java
- Variable in Java
- Type Casting in Java
- Wrapper Class in Java
- Modifiers in Java
Method
- Non-Parameterized Method
- Parameterized Method
Constructor
- Default Constructor or Non-Parameterized Constructor
- Parameterized Constructor
Blocks
- Static Block
- Non-Static block

Method is set of code or instruction to perform some operation.
It is used to represent the behaviour of an object.
A method must be declared within a class. It is defined with the name of the method, followed by parentheses ().
Rules for a method :
Method must have an access modifiers like private, default, protected or public.
Method has an optional to use non access modifiers like static, final, abstract, synchronized etc.
Method must have a return type.
Method must have a name or identifiers in which we call a method.
Method name should be declare in camel case like add(), addTwoNumber() etc.

Constructor is used to initialize the property.
Constructor must be the class name.
Constructor must have an access modifiers.
Constructor never have any non-access modifiers.
Constructor always call by the new keyword.
Constructor never have any return type.
Constructor always return same type of object.

Blocks are self executable.
Block has no name.
Block is used to perform some callback before initialized any thing.
Blocks are define inside class.

0 Comments