Answer is the letter A, basic inheritance question, remember that the subclass always inherits the methods of the superior classes by default before your first one, so it's C B A.
Not really the reaons. The main reason is that if your derived class doesn't call any super method explicitly, JVM will help you invoke a no-argument constructor of your parent class. In this case, when we construct A, it calls super() implicitly so the no-argument constructor of B is also called. By the same token, the no-argument constructor of C is also called.
Try to modify a bit of this question so that the constructor of C accepts some parameters, say public C(int test){ System.out.print("C ");}. JVM will raise a compilation error at line n1 as it cannot call any no-argument constructor of parent class C
As there will be a default no-argument constructor for every class if we don't specify any constructor for that class, in that case JVM will also call the default constructor and no error will be raised. Just remember that the constructor of any parent class must be called in Java.
upvoted 1 times
...
...
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
iSnover
3 months, 1 week agoalex_au
3 months, 1 week agoalex_au
3 months, 1 week ago