Exam 10: Polymorphism
Exam 1: Introduction65 Questions
Exam 2: Data and Expressions77 Questions
Exam 3: Using Classes and Objects58 Questions
Exam 4: Writing Classes56 Questions
Exam 5: Conditionals and Loops37 Questions
Exam 6: More Conditionals and Loops36 Questions
Exam 7: Object-Oriented Design76 Questions
Exam 8: Arrays70 Questions
Exam 9: Inheritance71 Questions
Exam 10: Polymorphism70 Questions
Exam 11: Exceptions68 Questions
Exam 12: Recursion68 Questions
Exam 13: Collections68 Questions
Select questions type
Consider this statement: If you declare a (polymorphic) reference variable, v, to be of type Object, by saying: Object v; then v can refer to any kind of object without restriction. If "object" means an instance of the Object class, is this statement True?
Why or why not?
If "object" means any kind of Java data, is this statement True?
Why or why not?
(Essay)
4.8/5
(42)
What is printed?
Public class Inherit
{
Class Figure
{
Void display( )
{
System.out.println("Figure");
}
}
Class Rectangle extends Figure
{
Void display( )
{
System.out.println("Rectangle");
}
}
Class Box extends Figure
{
Void display( )
{
System.out.println("Box");
}
}
Inherit( )
{
Figure f = new Figure( );
Rectangle r = new Rectangle( );
Box b = new Box( );
f.display( );
f = r;
f.display( );
F = b;
f.display( );
}
Public static void main(String[ ] args)
{
New Inherit( );
}
}
(Multiple Choice)
4.9/5
(31)
Which of the following GUI components would you use to display a list of options so that the user could select between the entries in the list?
(Multiple Choice)
4.9/5
(36)
A polymorphic reference can refer to different types of objects over time.
(True/False)
4.8/5
(35)
What is printed?
Public class Inherit
{
Abstract class Figure
{
Void display( )
{
System.out.println("Figure");
}
}
Abstract class Rectangle extends Figure
{
}
Class Box extends Rectangle
{
Void display( )
{
System.out.println("Rectangle");
}
}
Inherit( )
{
Figure f = (Figure) new Box( );
f.display( );
Rectangle r = (Rectangle) f;
r.display( );
}
Public static void main(String[ ] args)
{
New Inherit( );
}
}
(Multiple Choice)
4.8/5
(42)
Consider the code shown below. It contains a syntax error, preventing successful compilation and execution. What is the error?
public class Inherit
{
class Figure
{
void display( )
{
System.out.println("Figure");
}
}
class Rectangle extends Figure
{
final void display( )
{
System.out.println("Rectangle");
}
}
class Box extends Rectangle
{
void display( ) {
System.out.println("Box");
}
}
Inherit( )
{
Figure f = new Figure( );
Rectangle r = new Rectangle( );
Box b = new Box( );
f.display( );
r.display( );
b.display( );
}
public static void main(String[ ] args)
{
new Inherit( );
}
}
(Essay)
4.7/5
(41)
Which of these methods will sort an array of floats into ascending order?
(Multiple Choice)
5.0/5
(46)
What kind of performance can you expect if you perform linear search on a sorted array?
(Multiple Choice)
4.7/5
(38)
Showing 61 - 70 of 70
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)