
CAI710 - Inheritance

Quiz
•
Computers
•
12th Grade
•
Medium
Ayesha Abdullah
Used 12+ times
FREE Resource
8 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
A car dealership needs a program to store information about the cars for sale. For each car, they want to keep track of the following information: number of doors (2 or 4), whether the car has air conditioning, and its average number of miles per gallon. Which of the following is the best object-oriented program design?
Use one class, Car, with three instance variables:
int numDoors, boolean hasAir, and
double milesPerGallon
Use four unrelated classes: Car, Doors, AirConditioning, and MilesPerGallon.
Use a class Car with three subclasses: Doors, AirConditioning, and MilesPerGallon.
Use a class Car, with a subclass Doors, with a subclass
AirConditioning, with a subclass MilesPerGallon.
Use three classes: Doors, AirConditioning, and MilesPerGallon, each with a subclass Car.
2.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following class definitions.
public class ClassA
{
public String getValue()
{
return "A";
}
public void showValue()
{
System.out.print(getValue());
}
}
public class ClassB extends ClassA
{
public String getValue()
{
return "B";
}
}
The following code segment appears in a class other than ClassA or ClassB.
ClassA obj = new ClassB();
obj.showValue();
What, if anything, is printed when the code segment is executed?
A
B
AB
BA
Nothing
3.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
The following Syntax is used for?
class Subclass-name extends Superclass-name
{
//methods and fields
}
Polymorphism
Encapsulation
Inheritance
Incorrect syntax
4.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
A class that is inherited is called a ______ .
Subclass
SetClass
SuperClass
Child Class
5.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
Which Java statement represents inheritance?
Class Car inherits Vehicle
Class Car inherits Super Vehicle
Class Car Super Vehicle
Class Car extends Vehicle
Class Car Override Vehicle
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is/are false about inheritance in Java?
I. A subclass inherits all the methods and variables of the superclass.
II. A subclass can override the methods of its superclass
III. A subclass has access to the private instance variables of the superclass.
I only
II only
III only
I and II only
I, II and III only
7.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following code.
class Vehicle
{
int maxSpeed = 120;
}
class Car extends Vehicle
{
int maxSpeed = 180;
void display() {
System.out.println("Maximum Speed: " + super.maxSpeed);
}
}
/* Driver program to test */
class Test
{
public static void main(String[] args)
{
Car small = new Car(); small.display();
}
}
In the program output, what is the maximum speed displayed?
120
180
120 180
Nothing
8.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
In Java, each child class can have only one parent.
True
False
Similar Resources on Wayground
12 questions
CHANDRASHEEL VIDYAPEETH,KANTI,MUZ. [ROLE OF IT IN EDUCATION]

Quiz
•
9th - 12th Grade
6 questions
Object Orient Programming

Quiz
•
12th Grade
13 questions
Procedural and Object-oriented Languages Quiz

Quiz
•
12th Grade
7 questions
CSC703_T3_Milestone2_PC2.1_2.9_P_ID

Quiz
•
12th Grade
11 questions
Mini Assessment - OOP

Quiz
•
12th Grade
12 questions
Unit 9 topic 2 quiz

Quiz
•
9th - 12th Grade
10 questions
G12-CS-الوراثة - الدرس3

Quiz
•
12th Grade
10 questions
Object Oriented Programming

Quiz
•
12th Grade
Popular Resources on Wayground
18 questions
Writing Launch Day 1

Lesson
•
3rd Grade
11 questions
Hallway & Bathroom Expectations

Quiz
•
6th - 8th Grade
11 questions
Standard Response Protocol

Quiz
•
6th - 8th Grade
40 questions
Algebra Review Topics

Quiz
•
9th - 12th Grade
4 questions
Exit Ticket 7/29

Quiz
•
8th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
19 questions
Handbook Overview

Lesson
•
9th - 12th Grade
20 questions
Subject-Verb Agreement

Quiz
•
9th Grade
Discover more resources for Computers
40 questions
Algebra Review Topics

Quiz
•
9th - 12th Grade
19 questions
Handbook Overview

Lesson
•
9th - 12th Grade
62 questions
Spanish Speaking Countries, Capitals, and Locations

Quiz
•
9th - 12th Grade
20 questions
First Day of School

Quiz
•
6th - 12th Grade
6 questions
Maier - AMDM - Unit 1 - Quiz 1 - Estimation

Quiz
•
12th Grade
21 questions
Arithmetic Sequences

Quiz
•
9th - 12th Grade
21 questions
9th Grade English Diagnostic Quiz

Quiz
•
9th - 12th Grade
7 questions
Characteristics of Life

Interactive video
•
11th Grade - University