Medium Multiple Choice Questions on Inheritance

Medium Multiple Choice Questions on Inheritance

5th Grade

7 Qs

quiz-placeholder

Similar activities

HARI 2- QUIZ CODING DAN PERKENALAN AI

HARI 2- QUIZ CODING DAN PERKENALAN AI

1st - 6th Grade

12 Qs

Module 5 revision

Module 5 revision

2nd - 5th Grade

6 Qs

[SM] Data Type - Camera - Loudness

[SM] Data Type - Camera - Loudness

3rd - 8th Grade

8 Qs

Apache Ant para Estudiantes de Quinto Grado

Apache Ant para Estudiantes de Quinto Grado

5th Grade

8 Qs

Quiz y5

Quiz y5

5th Grade

10 Qs

Miau

Miau

1st - 12th Grade

5 Qs

Know Your Scratch Stage

Know Your Scratch Stage

4th - 6th Grade

11 Qs

Pengenalan AI (Faqih)

Pengenalan AI (Faqih)

2nd - 6th Grade

10 Qs

Medium Multiple Choice Questions on Inheritance

Medium Multiple Choice Questions on Inheritance

Assessment

Quiz

Computers

5th Grade

Hard

Created by

Caroline Hersh-Rodeen

FREE Resource

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