exam questions

Exam 1z0-808 All Questions

View all questions & answers for the 1z0-808 exam

Exam 1z0-808 topic 1 question 155 discussion

Actual exam question from Oracle's 1z0-808
Question #: 155
Topic #: 1
[All 1z0-808 Questions]

Given:

What is the result?

  • A. C B A
  • B. C
  • C. A B C
  • D. Compilation fails at line n1 and line n2
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
iSnover
3 months, 1 week ago
Selected Answer: A
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.
upvoted 2 times
alex_au
3 months, 1 week ago
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
upvoted 1 times
alex_au
3 months, 1 week ago
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
...
...
...
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.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago