Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1
In java: no, you have to create them, and inside the constructors of the derived class you call the base class' constructor, let me give you an example: public class Vehicle { int wheels; public Vehicle(int w) { wheels = w; } } public class Bike extends Vehicle { String color; public Bike(int wheels, String color) { //call super class constructor super(wheels); this.color = color; } } In c++ I don't remember.
13th Mar 2018, 6:12 AM
voidneo