Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
3 Cards in this Set
- Front
- Back
Will the following compile? public class Ferrari extends Car { public static void main(String [] args) { new Ferrari("C"); System.out.println(" "); } } |
No
Car does not have a no-arg constructor. However the constructor for Ferrari has an implied call to the super constructor, this call has no arguments. The lack of the no-arg constructor for Car causes the compilation error. |
|
Will the following compile? class Car { public class Ferrari extends Car { public static void main(String [] args) { new Ferrari("C"); System.out.println(" "); } } |
Yes The constructor for Ferrari actually calls the super class constructor explicitly, and passes in the required arguments. If you were to remove the call to super("abc"), it would fail compilation. |
|
|
|