Exam 10: Inheritance and Polymorphism
Exam 1: An Overview of Computers and Programming Languages50 Questions
Exam 2: Basic Elements of Java50 Questions
Exam 3: Introduction to Objects and Input/output50 Questions
Exam 4: Control Structures I: Selection50 Questions
Exam 5: Control Structures II: Repetition50 Questions
Exam 6: Graphical User Interface GUI and Object-Oriented Design OOD50 Questions
Exam 7: User-Defined Methods50 Questions
Exam 8: User-Defined Classes50 Questions
Exam 9: Arrays46 Questions
Exam 10: Inheritance and Polymorphism50 Questions
Exam 11: Handling Exceptions and Events50 Questions
Exam 12: Advanced Guis and Graphics48 Questions
Exam 13: Recursion50 Questions
Exam 14: Applications of Arrays Searching and Sorting and Strings50 Questions
Select questions type
Suppose there are three classes named Shape, Circle, and Square. What is the most likely relationship between them?
(Multiple Choice)
4.9/5
(42)
To determine whether a reference variable that points to an object is of a particular class type, Java provides the operator instanceof.
(True/False)
5.0/5
(34)
Suppose a class Car and its subclass Honda both have a method called speed as part of the class definition. rentalH refers to an object of the type Honda and the following statements are found in the code:rentalH.cost();
Super.speed();In the scenario described in the accompanying figure, what will the first statement do?
(Multiple Choice)
4.9/5
(39)
Consider the following class definitions.public class BClass
{
Private int x; public void set(int a) { x = a; } public void print(){ }
}public class DClass extends BClass
{
Private int y; public void set(int a, int b)
{
//Postcondition: x = a; y = b;
}
Public void print(){ }
}Which of the following is the correct definition of the method set of the class DClass?(i)
Public void set(int a, int b)
{
Super.set(a);
Y = b;
}(ii) public void set(int a, int b)
{
X = a;
Y = b;
}
(Multiple Choice)
5.0/5
(43)
Suppose that the class Mystery is derived from the class Secret. The following statements are legal in Java.Secret secRef;
Mystery mysRef = new Mystery();
secRef = mysRef;
(True/False)
4.8/5
(30)
A subclass can directly access protected members of a superclass.
(True/False)
4.8/5
(40)
In Java, you can automatically make a reference variable of a subclass type point to an object of its superclass.
(True/False)
4.8/5
(38)
A subclass inherits all its data members from the superclass; it has none of its own.
(True/False)
4.9/5
(44)
Suppose that the class Mystery is derived from the class Secret. Consider the following statements.Secret secRef = new Secret();
Mystery mysRef = new Mystery();Which of the following statements is legal in Java?
(i) secRef = mysRef;
(ii) mysRef = secRef;
(Multiple Choice)
4.8/5
(28)
In Java, stream classes are implemented using the inheritance mechanism.
(True/False)
4.9/5
(41)
In multiple inheritance, the subclass is derived from more than one superclass.
(True/False)
4.8/5
(37)
Showing 21 - 40 of 50
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)