11. CRC stands for
1. Class, Return value, Composition
2. Class, Responsibilities, Collaborations
3. Class, Responsibilities, Composition
4. Compare, Return, Continue
12. True or False: A static member method may refer to non-static member variables of the same class, but only after an instance of the class has been defined.
13. True or False: All static member variables are initialized to −1 by default.
14. True or False: When an object is passed as an argument to a method, the method can access the argument.
15. True or False: A method cannot return a reference to an object.
16. True or False: You can declare an enumerated data type inside a method.
17. True or False: Enumerated data types are actually special types of classes.
18. True or False: enum constants have a toString method.
> What is a compiler?
> Why are variable names like x not recommended?
> What is the difference between a syntax error and a logical error?
> The following is program expressed as English statements. What would it display on the screen if it was actual program? The variable x starts with the value 0. The variable y starts with the value 5. Add 1 to x. Add 1 to y. Add x and y, and store the re
> What will the following code segments print on the screen? int a, x = 23; a = x % 2; System.out.println(x + "\n" + a);
> What will the following code segments print on the screen? System.out.print("I am the incredible”) ; System.out.print("computing\nmachine”) ; System.out.print("\nand I will\namaze\n)” ; System.out.println("you.");
> What will the following code segments print on the screen? int freeze = 32, boil = 212; freeze = 0; boil = 100; System.out.println(freeze + "\n"+ boil + "\n");
> 1. The if statement is an example of a ___. 1. sequence structure 2. decision structure 3. pathway structure 4. class structure 2. This type of expression has a value of either true or false. 1. binary expression 2. decision expression 3. unconditional
> Write code that creates a Circle, with a radius of 30, and then creates a TranslateTransition object to animate it. The duration of the animation is 5 seconds. When the animation is played, the Circle object will start at (0, 100), and it will move to th
> 11. Which Scanner class method would you use to read a string as input? 1. nextString 2. nextLine 3. readString 4. getLine 12. Which Scanner class method would you use to read a double as input? 1. nextDouble 2. getDouble 3. readDouble 4. None of these;
> 1. Every complete statement ends with___. 1. period 2. parenthesis 3. semicolon 4. ending brace 2. The following data: 72 ‘A’ “Hello World” 2.8712 Are example of ___. 1. variables 2. literals 3. strings 4. none of these 3. A group of statements, such a
> 11. This is a named storage location in the computer’s memory. 1. class 2. key words 3. variable 4. operator 12. The Java compiler generates ___. 1. machine code 2. byte code 3. source code 4. HTML 13. JVM stands for _____. 1. Java Variable Machine 2
> 1. This part of the computer fetches instructions, carries out the operations commanded by the instructions, and produces some outcome or resultant information. 1. memory 2. CPU 3. Secondary Storage 4. Input device 2. A byte is made up of eight 1. CPUs
> 21. True or False: The controller class usually loads the FXML file and builds the scene graph. 22. True or False: You can use Scene Builder to register a controller class to a GUI. 23. True or False: Registering a controller class to a GUI automatical
> 11. A(n) is a name that identifies a component in the FXML file. 1. fx:name 2. fx:id 3. fx:component 4. fx:variable 12. In a JavaFX application, the class loads the FXML file and builds the scene graph. 1. main application 2. controller 3. event listene
> 1. A(n) is a method that automatically executes when a specific event occurs. 1. controller 2. event listener 3. initialize method 4. autoresponder 2. A is a tree-like hierarchical data structure that contains the components of a JavaFX GUI. 1. director
> 31. True or False: An object of the Frame class does not have a content pane. 32. True or False: In an overriding paint method, you should never call the superclass’s version of the paint method. 33. True or False: Once a Timer object has been starte
> 20. A Timer object generates this type of event. 1. action events 2. timer events 3. item events 4. interval events 21. The following Applet class method returns a URL object with the location of the HTML file that invoked the applet. 1. getHTMLlocation
> 11. In a class that extends JApplet or JFrame you override this method to get a reference to the Graphics object. 1. paint 2. paintComponent 3. getGraphics 4. graphics 12. In a class that extends JPanel you override this method to get a reference to the
> Assume myBox is a Rectangle object. Write the statement that rotates myBox 45 degrees about its center.
> 1. This section of an HTML document contains all of the tags and text that produce output in the browser window. 1. head 2. content 3. body 4. output 2. You place the tag in this section of an HTML document. 1. head 2. content 3. body 4. output 3. Eve
> 30. True or False: A JMenu object cannot contain other JMenu objects. 31. True or False: A JTextArea component does not automatically display scroll bars. 32. True or False: By default, a JTextArea component does not perform line wrapping. 33. True or
> 21. This method sets the intervals at which major tick marks are displayed on a JSlider component. 1. setMajorTickSpacing 2. setMajorTickIntervals 3. setTickSpacing 4. setIntervals 22. True or False: You can use code to change the contents of a read-onl
> 11. This is text that appears in a small box when the user holds the mouse cursor over a component. 1. mnemonic 2. instant message 3. tool tip 4. pop-up mnemonic 12. This is a key that activates a component just as if the user clicked it with the mouse.
> 21. True/False: In SQL, the not-equal-to operator is !=, which is the same as in Java. 22. True/False: When a ResultSet object is initially created, its cursor is pointing at the first row in the result set. 23. True/False: In a transaction, it is perm
> 11. This method is specified in the Statement interface, and should be used to execute a SELECT statement. 1. execute 2. executeUpdate 3. executeQuery 4. executeSelect 12. This method is specified in the Statement interface, and should be used to execut
> 1. This is the technology that makes it possible for a Java application to communicate with a DBMS. 1. DBMSC 2. JDBC 3. JDBMS 4. JDSQL 2. This is a standard language for working with database management systems. 1. Java 2. COBOL 3. SQL 4. BASIC 3. The
> 11. You use this class to create Border objects. 1. BorderFactory 2. BorderMaker 3. BorderCreator 4. BorderSource 12. True or False: A panel cannot be displayed by itself. 13. True or False: You can place multiple components inside a GridLayout cell.
> 1. With Swing, you use this class to create a frame. 1. Frame 2. SwingFrame 3. JFrame 4. JavaFrame 2. This is the part of a JFrame object that holds the components that have been added to the JFrame object. 1. content pane 2. viewing area 3. component a
> Write a statement that instantiates the Polygon class, and uses the constructor to draw a polygon with vertices at the following points: (100, 100), (200, 100), (200, 200), and (100, 200).
> 1. A method is called once from a program’s main method, and then it calls itself four times. The depth of recursion is ___. 1. one 2. four 3. five 4. nine 2. This is the part of a problem that can be solved without recursion. 1. base case 2. solvable
> 11. True or False: In a 640 by 480 window, the coordinates of the pixel in the upper-left corner are (0, 0). 12. True or False: In a 640 by 480 window, the coordinates of the pixel in the lower-right corner are (640, 480). 13. True or False: If an elli
> 1. Line, Circle, and Rectangle are subclasses of the ___ class. 1. Sprite 2. Geometry 3. BasicShape 4. Shape 2. Assume myCircle is a Circle object. Which of these statements causes myCircle to not be filled with a color? 1. myCircle.setColor(null) ; 2.
> 21. True or False: By default, ListView controls are oriented horizontally. 22. True or False: By default, TextArea controls perform line wrapping. 23. True or False: A MenuBar object acts as a container for Menu objects. 24. True or False: A Menu obj
> 11. The ____ control presents its items in a drop-down list.. 1. DropList 2. ListView 3. ComboBox 4. ItemList 12. Both the ListView control and the ComboBox control keeps its list of items in a(n) ____ object. 1. ArrayList 2. ExpandableList 3. ItemList
> 1. When a selector name starts with a period in a JavaFX CSS style definition, it means the selector corresponds to ____. 1. specific variable names in the application 2. specific types of JavaFX nodes 3. values that the user enters 4. named constants in
> 11. You use this class to actually display an image. 1. ImageView 2. ImageLoader 3. Image 4. Img 12. The EventHandler interface specifies a method named ___. 1. register 2. onClick 3. fire 4. handle 13. The BorderPane layout container has five regions
> 1. The primary purpose of this type of control is to display text. 1. Button 2. Label 3. Message 4. Text 2. This type of control appears as a rectangular region that can accept keyboard input from the user. 1. Button 2. Label 3. TextField 4. InputField
> 21. True or False: When an exception is thrown, the JVM searches the try statement’s catch clauses from top to bottom and passes control of the program to the first catch clause with a parameter that is compatible with the exception. 22. True or False
> 11. This method may be called from any exception object, and it shows the chain of methods that were called when the exception was thrown. 1. printInvocationList 2. printCallStack 3. printStackTrace 4. printCallList 12. These are exceptions that inherit
> Write a statement that instantiates the Rectangle class, and uses the constructor to draw a rectangle with its upper-left corner at (100, 200), with a width of 175, and a height of 150.
> 1. When an exception is generated, it is said to have been. 1. built 2. thrown 3. caught 4. killed 2. This is a section of code that gracefully responds to exceptions. 1. exception generator 2. exception manipulator 3. exception handler 4. exception mon
> 31. True or False: When a class contains an abstract method, the class cannot be instantiated 32. True or False: A class may only implement one interface. 33. True or False: By default all members of an interface are public.
> 21. You can use a lambda expression to instantiate an object that ___. 1. that has no constructor. 2. extends any superclass. 3. implements a functional interface 4. does not implement an interface. 22. True or False: Constructors are not inherited. 23
> 11. All classes directly or indirectly inherit from this class. 1. Object 2. Super 3. Root 4. Jaav 12. With this type of binding, the Java Virtual Machine determines at runtime which method to call, depending on the type of the object that a variable re
> 1. In an inheritance relationship, this is the general class. 1. subclass 2. superclass 3. slave class 4. child class 2. In an inheritance relationship, this is the specialized class. 1. superclass 2. master class 3. subclass 4. parent class 3. This ke
> 21. True or False: The String class’s replace method can replace individual characters, but cannot replace substrings. 22. True or False: The StringBuilder class’s replace method can replace individual characters, but cannot replace substrings. 23.
> 11. To delete a specific character in a StringBuilder object, use this method. 1. deleteCharAt 2. removeCharAt 3. removeChar 4. expunge 12. The character that separates tokens in a string is known as a ___. 1. separator 2. tokenizer 3. delimiter 4. term
> 1. The isDigit, isLetter, and isLetterOrDigit methods are members of this class. 1. String 2. Char 3. Character 4. StringBuilder 2. This method converts a character to uppercase. 1. makeUpperCase 2. toUpperCase 3. isUpperCase 4. uppercase 3. The starts
> 1. This type of method cannot access any non-static member variables in its own class. 1. instance 2. void 3. static 4. non-static 2. When an object is passed as an argument to a method, this is actually passed. 1. a copy of the object 2. the name of th
> Write a statement that instantiates the Line class, and uses the constructor to draw a line from (50, 25) to (150, 125).
> 21. True or False: The first size declarator in the declaration of a two-dimensional array represents the number of columns. The second size declarator represents the number of rows. 22. True or False: A two-dimensional array has multiple length fields.
> 11. To insert an item at a specific location in an ArrayList object, you use this method. 1. store 2. insert 3. add 4. get 12. To delete an item from an ArrayList object, you use this method. 1. remove 2. delete 3. erase 4. get 13. To determine the num
> 1. In an array declaration, this indicates the number of elements that the array will have. 1. subscript 2. size declarator 3. element sum 4. reference variable 2. Each element of an array is accessed by a number known as a(n) ___. 1. subscript 2. size
> 11. This is automatically provided for a class if you do not write one yourself. 1. accessor method 2. default instance 3. default constructor 4. variable declaration 12. Two or more methods in a class may have the same name, as long as this is differen
> 1. This is a collection of programming statements that specify the fields and methods that a particular type of object may have. 1. class 2. method 3. parameter 4. instance 2. A class is analogous to a(n) ___. 1. house 2. blueprint 3. drafting table 4.
> 11. True or False: When passing an argument to a method, Java will automatically perform a widening conversion (convert the argument to a higher-ranking data type), if necessary. 12. True or False: When passing an argument to a method, Java will automat
> 1. This type of method does not return a value. 1. null 2. void 3. empty 4. anonymous 2. This appears at the beginning of a method definition. 1. semicolon 2. parentheses 3. body 4. header 3. The body of a method is enclosed in ___. 1. curly braces { }
> 21. True or False: The for loop is a posttest loop. 22. True or False: It is not necessary to initialize accumulator variables. 23. True or False: One limitation of the for loop is that only one variable may be initialized in the initialization express
> 11. This expression is executed by the for loop only once, regardless of the number of iterations. 1. initialization expression 2. test expression 3. update expression 4. pre-increment expression 12. This is a variable that keeps a running total. 1. sen
> 1. What will the println statement in the following program segment display? int x = 5; System.out.println(x++); 1. 5 2. 6 3. 0 4. None of these 2. What will the println statement in the following program segment display? int x = 5; System.out.println(+
> Write the code to add the following RadioButton controls to the ToggleGroup. RadioButton radio1 = new RadioButton("Option 1"); RadioButton radio2 = new RadioButton("Option 2"); RadioButton radio3 = new RadioButton("Option 3"); ToggleGroup radioGroup = ne
> 11. When determining whether a number is inside a range, it’s best to use this operator. 1. && 2. ! 3. | | 4. ? : 12. This determines whether two different String objects contain the same string. 1. the == operator 2. the = operator 3. the equals meth
> Find the errors in the following code: The following statement should determine whether x is not greater than 20. What is wrong with it? if (!x > 20)
> Find the errors in the following code: // Warning! This code contains ERRORS! if (x == 1) ; y = 2 ; else if (x == 2) ; y = 3 ; else if (x == 3) ; y = 4 ;
> Find the errors in the following code: // Warning! This code contains ERRORS! if (num2 == 0) System.out.println("Division by zero is not possible."); System.out.println("Please run the program again ") ; System.out.println("and enter a number besides ze
> There are a number of syntax errors in the following program. Locate as many as you can. */ What's wrong with this program /* public MyProgram { public static void main(String[ ] args) ; } int a, b, c \\ Three integers a = 3 b = 4 c = a + b System.out.p
> The following pseudocode algorithm has an error. The program is supposed to ask the user for the length and width of a rectangular room, and then display the room’s area. The program must multiply the width by the length to determine the area. Find the
> The following import statements are in a controller class that uses a Button component and a Label component. import java.fxml.FXML; import java.scene.control.Button; import java.scene.control.Label;
> Find the error: private class MyMouseListener implements MouseListener { public void mouseClicked(MouseEvent e) { mouseClicks += 1; } }
> Find the error: // Force a call to the paint method paint();
> Find the error:
> An application has a Button control named calcButton. Write the statement that assigns the ID "calc-button" to the calcButton control.
> Find the error: // Create a text area with 20 columns and 5 rows. JTextArea textArea = new JTextArea (20, 5);
> Find the error: JLabel label = new JLabel("Have a nice day!"); label.setImage(image) ;
> Find the error: // Create a JList and add it to a scroll pane. // Assume that array already exists. JList list = new JList(array) ; JScrollPane scrollPane = new JScrollPane(); scrollPane.add(list) ;
> Find the error: // Create a read-only text field. JTextField textField = new JTextField(10); textField.setEditable(true);
> Find the error in the following Java code. Assume that conn references a valid Connection object. // This code has an error!!! String sql = "SELECT * FROM Coffee"; Statement stmt = conn.createStatement(); ResultSet result = stmt.execute(sql);
> Find the error in the following SQL statement. SELECT * FROM Coffee WHERE Description = "French Roast Dark”
> The panel variable references a JPanel object. The intention of the following statement is to create a titled border around panel: panel.setBorder(new BorderFactory("Choices"));
> The intention of the following statement is to give the panel object a GridLayout manager with 10 columns and 5 rows: panel.setLayout(new GridLayout(10, 5));
> The following statement is in a class that uses Swing components: import java.swing.*;
> Find the error in the following program: public class FindTheError { public static void main(String[] args) { myMethod(0); } public static void myMethod(int num) { System.out.print(num + " "); myMethod(num + 1); } }
> Write functional RGB notation for a color where red=100, green=20, and blue= 255.
> What will the following code output? int apples = 0, bananas = 2, pears = 10; apples += 10; bananas *= 10; pears /= 10; System.out.println(apples + " " + bananas + " " + pears);
> Find the error: // This code has an error! RadioButton radio1 = new RadioButton("Option 1"); RadioButton radio2 = new RadioButton("Option 2"); ToggleGroup radioGroup = new ToggleGroup(); radioGroup.setToggleGroup(radio1); radioGroup.setToggleGroup(radio2
> Find the error: .button { -fx-background-color = #0000FF; }
> Find the error: // This code has an error! myImageView.setWidth(100); myImageView.setHeight(100);
> Assume hbox is an HBox container: // This code has an error! hbox.setAlignment(CENTER);
> Find the error: // This code has an error! @Override public void start(Scene primaryScene) { primaryScene.show(); }
> Find the error: try { number = Integer.parseInt(str); } catch (Exception e) { System.out.println(e.getMessage()); } catch (IllegalArgumentException e) { System.out.println("Bad number format."); } catch (NumberFormatException e) { System.out.println(str
> Find the error: catch (FileNotFoundException e) { System.out.println("File not found."); } try { File file = new File("MyFile.txt"); Scanner inputFile = new Scanner(file); }
> Find the error: // Superclass public class Vehicle { private double cost; public Vehicle(double c) { cost = c; } } // Subclass public class Car extends Vehicle { private int passengers; public Car(int p) { passengers = c; } }
> Find the error: // Superclass public class Vehicle { (Member declarations . . .) } // Subclass public class Car expands Vehicle { (Member declarations . . .) }
> Find the error: // Change the very first character of a // StringBuilder object to 'Z'. str.setCharAt(1, 'Z');
> Write a JavaFX CSS style definition that will be applied to all Label, Button, and TextField controls. The style definition should specify the following: font size: 24, font style: italic, font weight: bold.
> Find the error: int number = 99; String str; // Convert number to a string. str.valueOf(number);
> The following class definition has an error. What is it? public class MyClass { private int x; private double y; public static void setValues(int a, double b) { x = a; y = b; } }
> String[] words = { "Hello", "Goodbye" }; System.out.println(words.toUpperCase());
> int[] table = new int[10]; for (int x = 1; x