0
How to create objects of subclasses/implemented classes in java. Sololearn only teaches how to create objects of simple classes.
class Ferrari extends Vehicle { //some code } class Conjuring extends Horror implements Hollywood { //some code } Create objects of Ferrari and conjuring
3 Antworten
+ 1
Science is Cool You have already started Java learning.
https://www.sololearn.com/learn/Java/2155/
+ 1
Sololearn just teaches to create objects from normal classes. I want to know how to create objects from subclasses / implemented classes
0
If you call
Ferrari f = new Ferrari();
it will use the fields of Class Ferrari.
If you call Vehicle v = new Vehicle ();
Its will use the fields of Vehicle
If you call Vehicle vf = new Ferrari ();
It will use the fields of Vehicle.
Same applies to methods.