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
A JSlider provides a list of String choices that the user can select between.
Free
(True/False)
4.8/5
(40)
Correct Answer:
False
What is printed?
public class Inherit
{
abstract class Figure
{
void display( )
{
System.out.println("Figure");
}
}
class Line extends Figure
{
void display( )
{
System.out.println("Line");
}
}
void tryme(Figure f)
{
f.display( );
}
Inherit( )
{
Figure f = new Line( );
tryme(f);
}
public static void main(String[ ] args)
{
new Inherit( );
}
}
Free
(Multiple Choice)
4.9/5
(37)
Correct Answer:
A
Which of the following classes would you use to open a GUI dialog box, which is then used to select a file to open?
Free
(Multiple Choice)
4.9/5
(37)
Correct Answer:
D
Write a set of code to define a vertical JSlider that goes from 1 to 1000 with tick marks every 100 and default to be set in the middle (at 500), with a background color of 0, 0, 255.
(Essay)
4.8/5
(39)
Assume that x is a GUI component from the javax.swing library. The instruction x.getValue( ) returns the value selected by the user from component x where x would be of which specific swing class?
(Multiple Choice)
4.8/5
(26)
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 Rectangle
{
void display( )
{
System.out.println("Box");
}
}
Inherit( )
{
Figure f = new Figure( );
Rectangle r = new Rectangle( );
Box b = new Box( );
f.display( );
f = r;
((Figure) f).display( );
f = (Figure) b;
f.display( );
}
public static void main(String[ ] args)
{
new Inherit( );
}
}
(Multiple Choice)
4.8/5
(34)
A class reference can refer to any object of any class that descends from the class.
(True/False)
4.8/5
(36)
What is printed by the following code? Consider the polymorphic invocation.
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.8/5
(34)
Binary search can be used on unsorted datait will just perform more slowly.
(True/False)
4.9/5
(42)
It is possible to sort an array of int, float, double or String, but not an array of an Object class such as a CD class.
(True/False)
4.8/5
(39)
Considering the event processing classes, what is the advantage of extending an adaptor class compared to implementing an interface?
(Multiple Choice)
4.7/5
(40)
One of the advantages of linear search is that it does not require its data to be sorted.
(True/False)
4.9/5
(39)
Write a set of code that will create 4 JButtons and add each of these to a JPanel so that they appear in a 2x2 grid. The JButtons will not have any text appear in them (i.e. no commands or names) but instead, will each appear as a color set by the user by using JColorChooser.
(Essay)
4.7/5
(34)
Write a set of code that will allow a user to select a file through a JFileChooser, read each item of the file, outputting each item to the screen, and close the file at the end.
(Essay)
4.7/5
(43)
Explain how to alter the Selection Sort algorithm so that it sorts in descending order instead of ascending order.
(Essay)
4.9/5
(42)
Write a set of code that will allow a user to select a file through a JFileChooser and store all items in the String array list to the selected file, closing the file when done.
(Essay)
4.8/5
(36)
Which of the following GUI components would you use to allow the user to move the view of the components within the container?
(Multiple Choice)
4.8/5
(33)
Regarding the Software Failure: There was a segment in the Ariana 5 software to convert a floating-point number to a signed 16-bit integer, but once the number was converted, it was out of range for 16 bits.
(True/False)
4.9/5
(31)
Showing 1 - 20 of 70
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)