
Unit 9 Quiz 1 Review

Quiz
•
Computers
•
9th - 12th Grade
•
Hard
Michael Courtright
Used 1+ times
FREE Resource
8 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following statements about Java hierarchies.
I. A class that is derived from another class is a subclass (also called a derived class, an extended class, or a child class). The class from which the subclass is derived is a superclass (also called a base class or a parent class).
II. Except for Object, which has no superclass, every class has one and only one direct superclass. In the absence of any other explicit superclass, every class is implicitly a subclass of Object.
III. Classes can be derived from classes that are derived from classes that are derived from classes, and so on, and they are all ultimately derived from the topmost class, Object.
Which of these statements is/are true?
I only
II only
III only
I and II
I, II, and III
Answer explanation
A class derived from another class is a subclass, and the class from which the subclass is derived is a superclass.
Derived classes can be derived from other derived classes. Every class has one and only one direct superclass.
2.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following Java hierarchy, in which A, B, and C are class objects.
Which of the following shows the correct use of the extends keyword to create the class hierarchy depicted above?
public class A { }
public class B extends A { }
public class C extends A { }
private class A { }
public class B extends A { }
public class C extends A { }
public class A { }
public class B { }
public class C { }
public class A { }
public class A extends B { }
public class A extends C { }
public class A extends B C { }
public class B { }
public class C { }
3.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
public class A {}
public class B extends A { }
public class C extends A { }
public class D extends B { }
public class E extends A { }
Which type of Java inheritance is depicted by the above code segment?
multilevel inheritance
single inheritance
hybrid inheritance
hierarchical inheritance
class inheritance
4.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Consider the following Java hierarchy, in which A, B, C, and D are class objects.
I only
II only
III only
I and II
I, II, and III
5.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
Which of the following statements about the Is-A and Has-A relationships is/are correct?
I. Is-A relationship: public class MountainBike extends Bike {}
II. Has-A relationship: class House { Kitchen kitchen = new Kitchen(); }
III. A Is-A relationship is a static (compile time) binding.
A Has-A relationship is dynamic (run time) binding.
I only
II only
III only
I and II
I, II, and III
6.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
public class Superclass { }
public class Subclass extends Superclass {
public static void main(String[] args) {
Subclass s = new Subclass(); }
}
How does Java handle the above situation, in which there is no explicit constructor defined for the subclass or its superclass?
If the subclass has no constructor, Java will not use any constructor from the superclass.
If a subclass does not have an explicit constructor, the compiler uses the default constructor from its superclass.
A subclass must have an explicit constructor.
Either the superclass or the subclass must have an explicit constructor.
A superclass must have an explicit constructor.
7.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
public class Superclass {
public String classTitle; }
public class Subclass extends Superclass {
public static void main(String[] args) {
Subclass subC = new Subclass();
/* Missing statement 1 / / Missing statement 2 */
} }
Which of the following shows the correct replacements for "Missing statement 1" and "Missing statement 2" if the code segment displays "Subclass" as an output?
subC.classTitle = "Subclass";
System.out.println(subC.classTitle);
classTitle = "Subclass";
System.out.println(classTitle);
superC.classTitle = "Subclass";
System.out.println(superC.classTitle);
subC.setclassTitle("Subclass");
System.out.println(subC.classTitle);
subC.classTitle("Subclass");
System.out.println(subC.classTitle);
8.
MULTIPLE CHOICE QUESTION
3 mins • 1 pt
public class Superclass {
private String classTitle; }
public class Subclass { }
What is the proper process for an instance of Subclass named subC to access the String variable classTitle?
Use the access methods for classTitle provided by the superclass.
subC.setclassTitle("Subclass");
subC.classTitle = "Subclass";
subC.classTitle("Subclass");
classTitle = "Subclass";
Similar Resources on Wayground
10 questions
Simulasi 3

Quiz
•
10th Grade
12 questions
Java G10 IT 1 - intro and conditionals

Quiz
•
10th Grade
11 questions
Object Oriented Programming

Quiz
•
12th Grade
10 questions
Inheritance Quiz

Quiz
•
2nd Grade - University
12 questions
Key Words: APCS A

Quiz
•
12th Grade
10 questions
Quarter 4 - LQ1 (Oracle Prog)

Quiz
•
12th Grade
8 questions
Object Oriented Programming Concepts

Quiz
•
12th Grade
12 questions
CodeHS Unit 1

Quiz
•
9th - 12th Grade
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
Discover more resources for Computers
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
10 questions
Proper Keyboarding Techniques

Interactive video
•
6th - 10th Grade
14 questions
Inputs and Outputs: Computer Science Intro

Lesson
•
5th - 9th Grade
10 questions
Understanding Computers: Hardware, Software, and Operating Systems

Interactive video
•
7th - 12th Grade
29 questions
AP CSP Unit 2 Review (Code.org)

Quiz
•
10th - 12th Grade