Skip to content

Commit 5e958b0

Browse files
committed
Section 13 Abstract Classes
Signed-off-by: https://github.com/Someshdiwan <[email protected]>
1 parent c79ad4c commit 5e958b0

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

Section13AbstractClasses/src/AbstractIMP.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ What happens if a subclass of an abstract class doesn't implement all the abstra
1111
Ans:
1212
If a subclass of an abstract class doesn't implement all the abstract methods, the subclass itself becomes abstract.
1313
This means that the subclass cannot be instantiated either. To create a concrete class, all abstract methods
14-
from the superclass must be implemented.
15-
16-
If you want to leave some methods unimplemented, you must declare the subclass as abstract as well:
14+
from the superclass must be implemented.
15+
If you want to leave some methods unimplemented, you must declare the subclass as abstract as well.
1716

1817
```java
1918
abstract class Shape {
@@ -26,10 +25,8 @@ abstract class Rectangle extends Shape {
2625
```
2726

2827
Yes, an abstract class can have a constructor in Java. Although abstract classes cannot be instantiated directly,
29-
they can have constructors.
30-
31-
These constructors are called when an instance of a concrete subclass is created.
32-
28+
they can have constructors.
29+
These constructors are called when an instance of a concrete subclass is created.
3330
Constructors in abstract classes are useful for initializing common fields or performing common setup operations for
3431
all subclasses.
3532

0 commit comments

Comments
 (0)