Skip to content

Commit 505c295

Browse files
authored
Create Constructor
1 parent 05cd527 commit 505c295

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

OOPs/Constructor

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Constructor
2+
3+
1. A constructor has the same name as the class.
4+
2. Default constructor has the access modifier of the class.
5+
3. A constructor can have any of the 4 access modifiers.
6+
4. A constructor has no return type.
7+
5. A constructor cannot be abstract, static, final or Synchronized.
8+
6. Complier creates a default constructor for ech class if we declare a parameterised constructor then default constructor is not made.
9+
7. Constructor is called only once.
10+
11+
Constructor Overloading
12+
13+
1. Multiple parameterised constructor can be used and overloaded.
14+
15+
Constructor Chaining
16+
17+
1. this() keyword is used to call constructor of the current class while super() is used to invoke the constructor of parent class.
18+
2. A constructor chaining appears to execute in the opposite direction of chain as the innermost constructor is executed first.

0 commit comments

Comments
 (0)