Originally posted by Abhijith Prabhakar:
Class B is not inheriting x, but compiler put a call to super class constructor.
super(); //Auto generated
So, while executing Class A constructor, x value will be outputted.
Originally posted by Raghavendra Nittur:
So Object of A also created
Originally posted by Joanne Neal:
No. Only one object is created and that is of type B. However this object will contain all the fields defined in A.
Originally posted by Stan James:
Because B truly is an A. It is everything A is plus more. You can't take anything away when you write B.
The private x still has to be there, no?
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koophttps://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton