Relative Content

Tag Archive for javapolymorphism

Java Polymorphism MOOC Quiz

I’m currently learning the basics of Java with the MOOC Java Programming II. I’ve reached this quiz but I don’t understand why the program is supposed to print 8 instead of 2.

Problems with Polymorphism in Java

I am going through the BroCode Java tutorial on YouTube, and unfortunately I am stuck on this Polymorphism example. I created a Vehicle parent class, as well as Boat, Bicycle, and Car child classes of the Vehicle class, all with their own overloaded void go(){} methods. I wanted to stick Boat boat1, Car car1, and Bicycle bike1 into Vehicle array, then iterate through said array and call each go method in it. Please let me know what problem I am having, and thank you in advance!