1
CSE205 Exam2 Study Guide Questions with
Correct Answers | Updated (100% Correct
Answers)
What is a polymorphic reference, and when are they resolved?—
Answer: A polymorphic reference is a reference variable that can
refer to different types of objects at different points in time.
Polymorphic references are resolved at run-time, not during
compilation.
Example: Pet myPet;
myPet = new Dog(); OR myPet = new Cat();
What is the comparable interface used for?— Answer: Java
Comparable interface is used to sort or order the objects of a user-
defined class, since Comparable cannot sort the objects on its own.
What is the signature of the method that
needs to be defined by the implementing the class?— Answer: int
compareTo(T object)
What methods do you use to get the location of the mouse when
implementing Mouse
© 2025 All rights reserved
, 2
Event?— Answer: Point point = event.getPoint(); or event.getX() &
event.getY();
What is an interface; can a class implement multiple interfaces?—
Answer: A java interface is a collection of abstract methods and
constants. A class
that implements an interface must define a definition for each
method in the interface.
Yes. A class can implement multiple interfaces.
If a class implements
the Comparator interface then it should implement what method?—
Answer: The compare method, int compare(T Object1, T Object2)
How do you draw a line?— Answer: Line line = new Line(startX,
startY, endX, endY);
How do you draw a circle?— Answer: Circle circle = new
Circle(centerX, centerY, radius);
How do you draw a text?— Answer: Text text = new Text(stratX,
startY, stringToDisplay);
When drawing a rectangle,
Rectangle r1 = new Rectangle(A, B, C, D);
© 2025 All rights reserved
CSE205 Exam2 Study Guide Questions with
Correct Answers | Updated (100% Correct
Answers)
What is a polymorphic reference, and when are they resolved?—
Answer: A polymorphic reference is a reference variable that can
refer to different types of objects at different points in time.
Polymorphic references are resolved at run-time, not during
compilation.
Example: Pet myPet;
myPet = new Dog(); OR myPet = new Cat();
What is the comparable interface used for?— Answer: Java
Comparable interface is used to sort or order the objects of a user-
defined class, since Comparable cannot sort the objects on its own.
What is the signature of the method that
needs to be defined by the implementing the class?— Answer: int
compareTo(T object)
What methods do you use to get the location of the mouse when
implementing Mouse
© 2025 All rights reserved
, 2
Event?— Answer: Point point = event.getPoint(); or event.getX() &
event.getY();
What is an interface; can a class implement multiple interfaces?—
Answer: A java interface is a collection of abstract methods and
constants. A class
that implements an interface must define a definition for each
method in the interface.
Yes. A class can implement multiple interfaces.
If a class implements
the Comparator interface then it should implement what method?—
Answer: The compare method, int compare(T Object1, T Object2)
How do you draw a line?— Answer: Line line = new Line(startX,
startY, endX, endY);
How do you draw a circle?— Answer: Circle circle = new
Circle(centerX, centerY, radius);
How do you draw a text?— Answer: Text text = new Text(stratX,
startY, stringToDisplay);
When drawing a rectangle,
Rectangle r1 = new Rectangle(A, B, C, D);
© 2025 All rights reserved