Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can anyone help with this questions? Suppose that we have the following classes: public class ClassA//Line 1 {private int x;//Line 2 protected void setX(int a)//Line

image text in transcribed

can anyone help with this questions?

Suppose that we have the following classes: public class ClassA//Line 1 {private int x;//Line 2 protected void setX(int a)//Line 3 {x =;//Line 4}} public class Test//Line 5 {public static void main(String [] args)//Line 6 {ClassA aObject;//Line 7 aObject.setX(4);//Line 8}} Explain the TWO reasons that make the above code incorrect? a) ______________ b) __________ 2. Suppose that Truck and Motorcycle are subclasses of Vehicle, Identify the following declarations as being valid or invalid. lf invalid tell why I. Truck t = new vehicle(); _________ ll. Vehicle v = new Truck(); ________. III. Motorcycle m1 = new vehicle(); IV. Motorcycle m2 = new Truck(); _________

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

MySQL/PHP Database Applications

Authors: Brad Bulger, Jay Greenspan, David Wall

2nd Edition

0764549634, 9780764549632

More Books

Students also viewed these Databases questions