File tree Expand file tree Collapse file tree 1 file changed +4
-7
lines changed
Section13AbstractClasses/src Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -11,9 +11,8 @@ What happens if a subclass of an abstract class doesn't implement all the abstra
1111Ans:
1212If a subclass of an abstract class doesn't implement all the abstract methods, the subclass itself becomes abstract.
1313This 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
1918abstract class Shape {
@@ -26,10 +25,8 @@ abstract class Rectangle extends Shape {
2625```
2726
2827Yes, 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.
3330Constructors in abstract classes are useful for initializing common fields or performing common setup operations for
3431all subclasses.
3532
You can’t perform that action at this time.
0 commit comments