File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ OverLoading rules
2+
3+ 1. Name of method should be same in each of the classes.
4+ 2. Return type and method argument can vary in each classes.
5+ 3. Inheritance is not necessary.
6+
7+
8+ OverRiding rules
9+ 1. Inheritance is required b/w parent and child classes.
10+ 2. Method argument and return type must be same in both the class's method
11+ 3. @Override annotation check if method is not overridden/implemented from it's superclass during complilation
12+ 4. The access modifier of subclass method should be same or wider than superclass's access modifier
13+ 5. If superclass throws error then subclass can either throw same,subclass of that error or no error
14+ 6. If superclass throws no error then subclass can only declare unchecked exceptions
15+
16+ private vs final (OverRiding)-
17+ 1. final method of superclass gives 'method final' error in compile time
18+ 2. private method of superclass gives no error rather it runs the local method
19+ using annotation in such cases gives no overriding done error
20+ When we create object/call of private then we get error
You can’t perform that action at this time.
0 commit comments