Exam 10: Polymorphism

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

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 the efficiency of binary search?

(Multiple Choice)
4.9/5
(39)

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)

We compare sorting algorithms by examining

(Multiple Choice)
4.8/5
(30)

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
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)