Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

BJP5 Self-Check 9.8: CarTruck Language/Type: J Java classes inheritance mystery. Author: Marty Stepp (on 2019/09/19) Consider the following two classes: public class Car { public

image text in transcribed
image text in transcribed
BJP5 Self-Check 9.8: CarTruck Language/Type: J Java classes inheritance mystery. Author: Marty Stepp (on 2019/09/19) Consider the following two classes: public class Car \{ public void m1() \{ \} System.out.println("car 1); public void m2() \} System.out.println("car 2); public String toString() \{ return "vroom"; \} . public class Truck extends Car \{ public void m1() \{ \} System.out.println("truck 1); And assuming that the following variables have been declared: Car mycar = new Car(); Truck mytruck = new Truck () ; What is the output from the following statements? System.out.print ln (mycar); public class Car \{ public void m1() \} System.out.println("car 1); public void m2() \{ \} System.out.println("car 2); public String toString() return "vroom"; \} public class Truck extends Car \{. public void m1() \{ System.out.println("truck 1); \} And assuming that the following variables have been declared: Car mycar = new Car(); Truck mytruck = new Truck(); What is the output from the following statements? System. out.println(mycar); mycar.m1(); mycar.m2(); System. out. println (mytruck); mytruck.m1()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design For Mere Mortals

Authors: Michael J Hernandez

4th Edition

978-0136788041

More Books

Students also viewed these Databases questions