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
What is the correct syntax for defining a new class Parakeet based on the superclass Bird?
Free
(Multiple Choice)
4.9/5
(40)
Correct Answer:
D
Consider the following class definitions.public class BClass
{
Private int x; public void set(int a)
{
X = a;
} public void print()
{
System.out.print(x);
}
}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 correctly redefines the method print of DClass?(i)
Public void print()
{
System.out.print(x + " " + y);
}(ii) public void print()
{
Super.print();
System.out.print(" " + y);
}
Free
(Multiple Choice)
4.9/5
(36)
Correct Answer:
B
Based on the diagram in the accompanying figure, the method setDimension in the class Box ____ the method setDimension in the class Rectangle.
Free
(Multiple Choice)
4.8/5
(30)
Correct Answer:
A
Suppose that the class Mystery is derived from the class Secret. Consider the following statements.Secret mySecret = new Secret();
Secret secRef;Mystery myMystery = new Mystery();
Mystery mysRef;secRef = myMystery;Which of the following statements is legal in Java?
(i) mysRef = (Mystery) mySecret;
(ii) mysRef = (Mystery) secRef;
(Multiple Choice)
4.7/5
(53)
An abstract method is a method that has only the heading with no body.
(True/False)
5.0/5
(33)
To override a public method of a superclass in a subclass, the corresponding method in the subclass must have the same name but a different number of parameters.
(True/False)
4.8/5
(28)
The private members of a superclass can be accessed by a subclass.
(True/False)
4.8/5
(35)
Which of the following statements about the reference super is true?
(Multiple Choice)
4.8/5
(26)
Interfaces are defined using the reserved word interface and the reserved word class.
(True/False)
4.8/5
(40)
You must always use the reserved word super to use a method from the superclass in the subclass.
(True/False)
4.8/5
(34)
A polymorphic reference variable can refer to either an object of its own class or an object of the subclasses inherited from its class.
(True/False)
5.0/5
(42)
Consider the following class definitions.public class BClass
{
Private int x;
Private double y; public void print() { }
}public class DClass extends BClass
{
Private int a;
Private int b; public void print() { }
}Suppose that you have the following statement.DClass dObject = new DClass();How many instance variables does dObject have?
(Multiple Choice)
4.7/5
(44)
The method toString() is a public member of the class ____.
(Multiple Choice)
4.8/5
(35)
If a class is declared final, then no other class can be derived from this class.
(True/False)
4.8/5
(38)
Based on the diagram in the accompanying figure, which of the following members will Box NOT have direct access to?
(Multiple Choice)
4.9/5
(34)
In dynamic binding, the method that gets executed is determined at compile time, not at execution time.
(True/False)
4.8/5
(31)
Redefining a method of a superclass is also known as overloading a method.
(True/False)
4.9/5
(42)
The class Object is directly or indirectly the superclass of every class in Java.
(True/False)
4.9/5
(43)
An interface is a class that contains only abstract methods and/or named constants.
(True/False)
4.9/5
(34)
Showing 1 - 20 of 50
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)