CJCoding With Joseph

Constructor Chain Trace

Constructors run from the top of the hierarchy down. A's constructor prints A constructor. Create B : A whose constructor prints B constructor, and C : B whose constructor prints C constructor. Because base constructors run first, creating a C prints all three lines top-down. Do NOT write a Main method.

When the tester creates a C, the program prints:
A constructor
B constructor
C constructor

Expected Output:

A constructor
B constructor
C constructor
Topics:
Inheritance
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cw, cr, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.