How to create objects of subclasses/implemented classes in java. Sololearn only teaches how to create objects of simple classes. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

1st Jul 2020, 10:08 AM
Vishal Vishwajeet
Vishal Vishwajeet - avatar
3 Answers
+ 1
Science is Cool You have already started Java learning. https://www.sololearn.com/learn/Java/2155/
1st Jul 2020, 10:17 AM
A͢J
A͢J - avatar
+ 1
Sololearn just teaches to create objects from normal classes. I want to know how to create objects from subclasses / implemented classes
1st Jul 2020, 10:20 AM
Vishal Vishwajeet
Vishal Vishwajeet - avatar
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.
1st Jul 2020, 10:16 AM
Blue!!
Blue!! - avatar