Search Header Logo

Medium Multiple Choice Questions on Inheritance

Authored by Caroline Hersh-Rodeen

Computers

5th Grade

Medium Multiple Choice Questions on Inheritance
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

7 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

2 mins • 3 pts

Media Image

Given the following class declarations, what is the output from Student s1 = new GradStudent(); followed by s1.getInfo();?

Won't compile since GradStudent doesn't have a getInfo method

Taco

Pizza

Won't compile since you are creating a GradStudent, not a Student

Won't compile since you use this.getFood()

2.

MULTIPLE CHOICE QUESTION

2 mins • 3 pts

Media Image

Given the following class declarations, and EnhancedItem enItemObj = new EnhancedItem(); in a client class, which of the following statements would compile?

I only

II only

I and II only

II and III only

I, II, and III

3.

MULTIPLE CHOICE QUESTION

2 mins • 3 pts

Media Image

Given the following class declarations and initializations in a client program, which of the following is a correct call to method1?

t1.method1(t1,t1);

t2.method1(t2,t2);

t3.method1(t1,t1);

t2.method1(t3,t2);

t3.method1(t3,t3);

4.

MULTIPLE CHOICE QUESTION

2 mins • 3 pts

Media Image

If you have a parent class Animal that has a method speak() which returns: Awk. Cat has a speak method that returns: Meow. Bird does not have a speak method. Dog has a speak method that returns: Woof. Pig does not have a speak method. Cow has a speak method that returns: Moo. What is the output from looping through the array a created below and asking each element to speak()?

Meow Moo Woof Awk Awk

Awk Awk Awk Awk Awk

This will not compile

This will have runtime errors

Meow Moo Woof Oink Awk

5.

MULTIPLE CHOICE QUESTION

2 mins • 3 pts

Media Image

Given the following class declarations and code, what is the result when the code is run?

The code compiles and runs with no errors, the output is 5 6 5 6

The code compiles and runs with no errors, the output is: 5 6 10 11

The code compiles and runs with no errors, the output is 10 11 10 11

The code won't compile.

You get a runtime error ClassCastException, when fastCar.addFuel() is executed.

6.

MULTIPLE CHOICE QUESTION

2 mins • 3 pts

Media Image

Given the following class declarations and code, what is the result when the code is run?

I only

II only

I and III only

III only

I, II, and III

7.

MULTIPLE CHOICE QUESTION

2 mins • 3 pts

Media Image

What is the output of the following code?

Meow Screeech Lasagna

Screeech Meow Lasagna

Lasagna Meow Screeech

Lasagna Screeech Meow

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?