Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Hi, Pankaj! I have found a small typo in the list of important points: “Subclass members with default access is accessible to subclass ONLY if they are in same package.” Seems it has to start with “Superclass members…” Anyway great tutorial, thank you!
- Evgeniy
Hi Pankaj, Would you please brief me the below point “If superclass doesn’t have default constructor, then subclass also needs to have an explicit constructor defined. Else it will throw compile time exception. In the subclass constructor, call to superclass constructor is mandatory in this case and it should be the first statement in the subclass constructor.” As per my understanding ,Java compiler inserts a default constructor into the code during compilation and exists in .class file . Could you please explain me how can we create a super class without a default constructor.
- Kishan
why we don’t write getter and setter method for private int noofleg… plz describe
- CHINTUL
Hi Pankaj, your article are too good man, i like the detail explanation about the topic which is given by you, i also like the interview question section provided by you, thank, really appreciate your work.
- prashant pardhi
There’s a typo error at the example in point 11. Please, add examples at some points (let’s say: points 9 and 10, and others). Thanks for your help.
- Carlos
Just a correction in the wording: ////When an instance of Superclass is assigned to a Subclass variable, then it’s called downcasting. We need to explicitly cast this to Subclass./// The instance is of sub class which is referred by Superclass variable. I mean the object instance is of Cat type, just that it is referened by superclass variable and we want to downcast it to subclass variable.
- Pragun
Design the given inheritance in C++ .Note that bus and truck are friend classes and can work as a bridge. Also create a function which calculates total no of visits per day of both (bus and truck) and find total fuel cost of the day.
- sheriyar