Difficulty: Easy
Correct Answer: BaseBase
Explanation:
Introduction / Context:
This question checks your understanding of Java constructor chaining during inheritance and the effect of creating instances on standard output. The subclass Alpha does not declare a constructor, so the compiler provides a default no-argument constructor that implicitly invokes super().
Given Data / Assumptions:
Concept / Approach:
When a class has no explicitly declared constructor, Java provides a default constructor that calls super(). Therefore, new Alpha() first constructs its Base subobject by invoking Base(), which prints "Base". Alpha itself does not print anything. The second expression new Base() again calls Base(), printing "Base" a second time. Standard output is simply the concatenation of those prints, with no newline characters added by this code.
Step-by-Step Solution:
Verification / Alternative check:
If Alpha had its own constructor printing, the output would include that text too. As written, only Base prints.
Why Other Options Are Wrong:
Common Pitfalls:
Forgetting the implicit super() call in the compiler-provided default constructor.
Final Answer:
BaseBase
Discussion & Comments