
Medium Multiple Choice Questions on Inheritance

Quiz
•
Computers
•
5th Grade
•
Hard
Caroline Hersh-Rodeen
FREE Resource
7 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
2 mins • 3 pts
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
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
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
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
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
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
What is the output of the following code?
Meow Screeech Lasagna
Screeech Meow Lasagna
Lasagna Meow Screeech
Lasagna Screeech Meow
Similar Resources on Wayground
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade