To fix the compilation error in the given code, we need to understand the concept of abstract classes and methods in Java.
An abstract class is a class that cannot be instantiated, and it can have abstract methods, which are declared without an implementation. Any subclass of an abstract class must either implement all the abstract methods of its parent class or be declared as abstract itself.
In the given code, we have an abstract class AirPlane
and its subclass AirJet
. AirPlane
has one abstract method fly()
and one non-abstract method land()
, while AirJet
overrides the fly()
method and declares another abstract method land()
.
The compilation error in the code is due to the fact that AirJet
is not implementing all the abstract methods of its parent class AirPlane
. To fix this error, we have two options:
a) Remove abstract from line 20 and add body to method land()
This option is correct. Since AirJet
is a concrete class, it must implement all the abstract methods of its parent class AirPlane
. Therefore, we can remove the abstract
keyword from the declaration of land()
method and provide an implementation for it.
b) Declare class AirJet as abstract to at line 10
This option is incorrect. Declaring AirJet
as abstract
will not solve the compilation error. In fact, it will introduce another error because AirJet
will now have two abstract methods, but it is not declaring itself as abstract.
c) Remove super() call at line 13
This option is incorrect. Removing the super()
call will not solve the compilation error. In fact, it will introduce another error because AirPlane
does not have a default constructor, and super()
is trying to call it.
d) Remove abstract at line 1 and line 2
This option is incorrect. Removing the abstract
keyword from line 1 and line 2 will not solve the compilation error. In fact, it will introduce another error because now AirPlane
will have a non-implemented method.
Therefore, the correct answer is:
The Answer is: A. a, b