Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Different ways of object creation

1. Using new keyword. Tester tester1 = new Tester();


2. Using Class.forName() method. Tester tester2 = (Tester)Class.
forName("Tester"). newInstance();
3. Using clone method. Tester tester3 = tester1.clone();
4. Using Constructor.forName() method Tester tester4 =
Tester.class.getConstructor().newInstance();
5. Using Deserialization

 Inner classes :
The class which declare inside the body of another class is called inner
class. These classes can have access modifier.
 Association:
Relation between two separate classes which establishes through
their Objects. It can be one-to-one, many-to-many relation etc
Implementation:

 Composition:
Composition is a (strong) Has-a relationship in java. It is the
design technique to implement has-a relationship in classes .
Implementation:

 Aggregation:
It is a one way relationship between two object
In Java, aggregation represents (weak) HAS-A relationship.
Implementation:
- Singleton Pattern
- Builder Pattern
- Prototype pattern:

You might also like