






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







What is a polymorphic reference, and when are they resolved? - correct answers ✅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? - correct answers ✅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? - correct answers ✅int compareTo(T object) What methods do you use to get the location of the mouse when implementing Mouse Event? - correct answers ✅Point point = event.getPoint(); or event.getX() & event.getY(); What is an interface; can a class implement multiple interfaces? - correct answers ✅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? - correct answers ✅The compare method, int compare(T Object1, T Object2) How do you draw a line? - correct answers ✅Line line = new Line(startX, startY, endX, endY); How do you draw a circle? - correct answers ✅Circle circle = new Circle(centerX, centerY, radius); How do you draw a text? - correct answers ✅Text text = new Text(stratX, startY, stringToDisplay); When drawing a rectangle, Rectangle r1 = new Rectangle(A, B, C, D); A and B specify what property of the rectangle to be drawn? C and D represent what other property? - correct answers ✅A and B specify the co-ordinate of top-left corner of the rectangle. A specifies the x coordinate and B specifies the y co-ordinate.
What layout manager could you use to place components in 4 columns over 7 rows? - correct answers ✅GridPane How does java handle exceptions? - correct answers ✅In java, exceptions are handled using two ways:
If you want to display three components vertically in a container of any size, what layout could you NOT use? - correct answers ✅If I want to display three components vertically in a container of any size, I could not use HBox layout. Selection sort - correct answers ✅replace first number in array with lowest number in list, and keep doing that with the 2nd, 3rd, and so on. just make sure to not include the numbers from previous in the array as you move on. Insertation Sort - correct answers ✅Sorts an array starting from 0, and going numerically up in the index until the end. If its more then the last index, it stays and you move on, if its less then you put it where it belongs on the left. Classes in a software system can have various types of relationships to each other. What are three of the most common relationships? - correct answers ✅1.Dependency - A uses B 2.Aggregation - A has-a B 3.Inheritance - A is-a B
have only abstract methods. A normal inherited class can't have any abstract methods. -Variables declared in a java interface are by default final. Abstract classes and inherited classes can have non-final variables. -Members of an interface are public by default. An abstract class and inherited class can have non-public members also. Abstract methods are used when defining _____. - correct answers ✅interface classes A variable declared to be of one class can later reference an extended class of that class. This variable is known as _____. - correct answers ✅polymorphic Which of the following is not a method of the Object class? - correct answers ✅compareTo All classes in Java are directly or indirectly subclasses of the _______ class. - correct answers ✅Object Use the following partial class definitions: public class A {
public int x; private int y; protected int z; ... } public class A2 extends A { protected int a; private int b; ... } public class A3 extends A { private int q; ... } Which of the following lists of instance data are accessible in A3? - correct answers ✅x, z, a, q True or False: An array, when instantiated, is fixed in size, but an ArrayList can dynamically change in size when new elements are added to it. - correct answers ✅True
Which of the following layout managment organizes the nodes from left to right, starting new rows as necessary? - correct answers ✅FlowPane What are the objects needed in order to create a Java FX GUI (graphical user interface) that responds to user action(s)? - correct answers ✅All of the above (Control, Event, Listener) True or False: A simple JavaFX program executes on a stage, which represents the window in which the application runs. - correct answers ✅True True or False: A TextArea can be used to display text, but not to edit text by the user. - correct answers ✅False Assume Exceptionname is a checked exception. If a method uses a class that can generate Exceptionname, then either the method must include try and catch statements where a catch statement catches Exceptionname, or the method header must include the statement - correct answers ✅throws Exceptionname _________ the process of using the same method name for multiple methods with different definitions when their signatures are different. - correct answers ✅Method overloading
True or False: A combo box allows the user to select one of several options from a "drop down" menu. - correct answers ✅True What is the code for drawing a red circle with center at (100, 100) with a radius 25? - correct answers ✅Circle shape1 = new Circle(100, 100, 25); shap1.setFill(Color.RED); Which method must be implemented if a class implements EventHandler interface? - correct answers ✅public void handle(ActionEvent e) Which code below draws a letter "V" by drawing two line segments? - correct answers ✅Line shape1 = new Line(0, 0, 10, 30); Line shape1 = new Line(10, 30, 20, 0); If you have a text field called, textField, that is suppose to hold an integer, what expression do you use to read its contents? - correct answers ✅Integer.parseInt(textField.getText()) True or False: The Towers of Hanoi puzzle cannot be solved iteratively. - correct answers ✅False