COP2800 - Final

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

How would a stylesheet named javafxstyles.css be applied to a JavaFX application, assuming that scene is the variable that refers to a Scene object? A) scene.getStylesheets().add(javafxstyles.css); B) scene.getStyles().add("javafxstyles.css"); C) scene.getStylesheets().add("javafxstyles.css"); D) scene.addStylesheets().get("javafxstyles.css");

C) scene.getStylesheets().add("javafxstyles.css");

To apply specific styles to all of the nodes in a scene, use the selector. A) .root B) .all C) .stage D) .top

A) .root

In the following statement, which is the subclass? public class ClassA extends ClassB implements ClassC A) ClassA B) ClassB C) ClassC D) Both ClassB and ClassC are subclasses.

A) ClassA

A method that calls itself is a _____ method. A) recursive B) redundant C) derived D) binary

A) recursive

In the , we must always reduce the problem to a smaller version of the original problem. A) recursive case B) base case C) partition case D) lessening case

A) recursive case

In memory, GUI objects in a are organized as in a tree-like hierarchical data structure. A) scene, nodes B) scene graph, methods C) node, scenes D) scene graph, nodes

A) scene, nodes

When using the throw statement, if you don't pass a message to the exception object's constructor, A) the exception will have a null message B) a compiler error will occur C) the exception will have a message containing the address of the exception D) the exception will have a default message describing the exception

A) the exception will have a null message

Given the following styles, what size will the text of myLabel be? .root { -fx- font-size: 12pt; } .label { -fx- font-size: 18pt; } A) 15 pts B) 18 pts C) 12 pts D) This will cause an error because there are duplicate font-size styles.

B) 18 pts

What happens when the following code is executed? ComboBox myComboBox = new ComboBox<>(); myComboBox.getItems().addAll(5, 10, 15, 20); A) The values 5, 10, 15, and 20 will be converted to strings and added a new ComboBox named myComboBox. B) A compiler error will occur. C) The values 5, 10, 15, and 20 will be added to a ComboBox named myComboBox. D) A ComboBox displaying the numbers 5, 10, 15, and 20 will be created. 162)

B) A compiler error will occur.

The foundation of a GUI application is the A) Stage object. B) Application class. C) Scene object. D) start method.

B) Application class

In the following statement, which is the superclass? public class ClassA extends ClassB implements ClassC A) ClassA B) ClassB C) ClassC D) Both ClassB and ClassC are superclasses.

B) ClassB

Unchecked exceptions are those that inherit from the A) ExceptionClass class or the RuntimeException class. B) Error class or the RuntimeException class. C) Error class or the Exception class. D) Error class.

B) Error class or the RuntimeException class.

All of the exceptions that you will handle are instances of classes that extend the class. A) RunTimeException B) Exception C) IOException D) Error

B) Exception

To read data from a binary file, you create objects from which of the following classes? A) File and PrintWriter B) FileInputStream and DataInputStream C) BinaryFileReader and BinaryDataReader D) File and Scanner

B) FileInputStream and DataInputStream

The ___ layout container arranges the contents into cells, similar to a spreadsheet. A) GridPaneObj B) GridPane C) CellPane D) GRID

B) GridPane

The control uses a drop-down list as its display. A) TextList B) ListView C) DropList D) ItemList

B) ListView

Assume the class BankAccount has been created and the following statement correctly creates an instance of the class. BankAccount account = new BankAccount(5000.00); What is true about the following statement System.out.println(account); A) A runtime error will occur. B) The account object's toString method will be implicitly called. C) The method will display unreadable binary data on the screen. D) A compiler error will occur.

B) The account object's toString method will be implicitly called.

Adding RadioButton controls to a object creates a mutually exclusive relationship between them. A) ExcludeGroup B) ToggleGroup C) MutualGroup D) RadioGroup

B) ToggleGroup

To serialize an object and write it to the file, use the method of the ObjectOutputStream class. A) SerializeObject B) WriteObject C) SerializeAndWrite D) Serialize

B) WriteObject

A class becomes abstract when you place the ___ key word in the class definition. A) final B) abstract C) extends D) super

B) abstract

The is at least one case in which a problem can be solved without recursion. A) termination point B) base case C) point of absolution D) recursive case

B) base case

Which key word indicates that a class inherits from another class? A) final B) extends C) super D) implements

B) extends

If a random access file contains a stream of characters, which of the following statements would move the file pointer to the starting byte of the fifth character in the file? A) file.seek(4); B) file.seek(8); C) file.seek(5); D) file.seek(10);

B) file.seek(8);

When you write a method that throws a checked exception, you must A) override the default error method. B) have a throws clause in the method header. C) ensure that the error will occur at least once each time the program is executed. D) use each class only once in a method.

B) have a throws clause in the method header.

One important difference between the command line interface and a GUI interface is that A) users must type information in a command line interface but, when using a GUI, typing is never required. B) in a GUI environment the user determines the order in which things happen while the user has no control over the order or events in a command line interface. C) in command line the background color of the monitor will always be black but in a GUI it can be any color. D) All of these are important differences.

B) in a GUI environment the user determines the order in which things happen while the user has no control over the order or events in a command line interface.

Which package contains the Insets class? A) javafx.layout B) javafx.geometry C) javafx.Insets D) javafx.scene

B) javafx.geometry

When writing a string to a binary file or reading a string from a binary file, it is recommended that you use A) the System.In and System.out methods. B) methods that use UTF-8 encoding. C) the FileReader and Writer class methods. D) the Scanner class methods.

B) methods that use UTF-8 encoding.

When a class does not use the extends key word to inherit from another class, Java automatically extends it from the ____ class. A) superclass B) Object C) public D) subclass

B) object

If you set a scene's size to a width and height that is smaller than the width and height of the image to be displayed, A) the image will automatically be resized to fit the window. B) only part of the image will be displayed. C) the image will only occupy part of the window. D) the scene will automatically be resized to fit the image.

B) only part of the image will be displayed.

Which of the following statements will set a ListView control, puppyListView, to be 300 pixels high and 200 pixels wide? A) puppyListView.setPrefSize(300, 200); B) puppyListView.setPrefSize(200, 300); C) puppyListView.setSize(300, 200); D) puppyListView.setSize(200, 300); 164)

B) puppyListView.setPrefSize(200, 300);

Like a loop, a recursive method must have which of the following? A) a control variable initialized to a starting value B) some way to control the number of time it repeats C) a statement that increments the control variable D) All of these

B) some way to control the number of time it repeats

In a JavaFX CSS style definition, if a selector name starts with a period, that selector corresponds to a A) named color. B) specific JavaFX node. C) specific variable in the application. D) value entered by the user.

B) specific JavaFX node.

When an exception is thrown by code in its try block, the JVM begins searching the try statement for a catch clause that can handle it and passes control of the program to A) the last catch clause that can handle the exception. B) the first catch clause that can handle the exception. C) each catch clause that can handle the exception. D) the statement that appears immediately after the catch block.

B) the first catch clause that can handle the exception.

You can use the enum key word to A) create your own data type. B) specify the values that belong to the type. C) F Neither of these D) F Both of these

Both of these

Protected class members can be denoted in a UML diagram with the symbol. A) - B) + C) * D) #

D) #

What will the following code display? String input = "99#7"; int number; try { number = Integer.parseInt(input); } catch(NumberFormatException ex) { number = 0; } catch(RuntimeException ex) { number = 1; } catch(Exception ex) { number = -1; } System.out.println(number); A) 1 B) -1 C) 99 D) 0

D) 0

Which of the following is a CSS named color? A) maroon B) lavender C) crimson D) All of these

D) All of these

After the header, the body of the method appears inside a set of A) braces, { } B) parentheses, ( ) C) double quotes, " " D) brackets, [ ]

braces

A(n) ___ method is a method that appears in a superclass but expects to be overridden in a subclass. A) abstract B) static C) overloaded D) protected

abstract

All fields declared in an interface A) have private access. B) are treated as final and static. C) must be initialized in the class implementing the interface. D) have protected access.

are treated as final and static

By default, a reference variable that is an instance field is initialized to the value A) 0 B) null C) static D) void

null

When an event takes place, the control responsible for the event creates an event A) firing. B) handler. C) source. D) object.

D) object.

Class objects normally have that perform useful operations on their data, but primitive variables do not. A) instances B) relationships C) methods D) fields

methods

A ____ member's access is somewhere between public and private. A) protected B) package C) static D) final

protected

Which symbol indicates that a member is public in a UML diagram? A) # B) * C) + D) -

+

Which symbol indicates that a member is private a UML diagram? A) * B) # C) - D) +

-

If you have defined a class, SavingsAccount, with a public static method, getNumberOfAccounts, and created a SavingsAccount object referenced by the variable account20, which of the following will call the getNumberOfAccounts method? A) SavingsAccount.getNumberOfAccounts(); B) account20.getNumberOfAccounts(); C) SavingsAccount.account20.getNumberOfAccounts(); D) getNumberOfAccounts();

SavingsAccount.getNumberOfAccounts();

What is the following statement an example of? import java.util.Scanner; A) a wildcard import statement B) an explicit import statement C) an unconditional import statement D) a conditional import statement

an explicit import statement

When an object is created, the attributes associated with the object are called A) fixed attributes. B) instance fields. C) class instances. D) instance methods.

instance fields

Methods that operate on an object's fields are called A) instance variables. B) public methods. C) private methods. D) instance methods.

instance methods

Using the blueprint/house analogy, you can think of a class as a blueprint that describes a house and _ as instances of the house built from the blueprint. A) attributes B) objects C) fields D) methods

objects

When a field is declared static there will be A) two reference copies of the field for each method in the class. B) only one copy of the field in memory. C) a copy of the field in each class object. D) a copy of the field for each method in the class.

only one copy of the field in memory

Enumerated types have the method which returns the position of an enum constant in the declaration list. A) ordinal B) location C) index D) position

ordinal

If a method in a subclass has the same signature as a method in the superclass, the subclass ____ method the superclass method. A) overloads B) overrides C) inherits D) implements

overrides

If you don't provide an access specifier for a class member, the class member is given ___ access by default. A) package B) public C) protected D) private

package

A constructor is a method that A) returns an object of the class. B) performs initialization or setup operations. C) removes the object from memory. D) never receives any arguments.

performs initialization or setup operations

In Java, a reference variable is ___ because it can reference objects of types different from its own, as long as those types are related to its type through inheritance. A) dynamic B) public C) polymorphic D) static

polymorphic

The scope of a local variable is A) the method in which it is defined. B) inside the class but not inside any method. C) the entire class. D) inside the parentheses of a method header.

the method in which it is defined

A method's signature consists of A) the return type, the method name, and the parameter list. B) the size of the method in memory. C) the return type and the method name. D) the method name and the parameter list.

the method name and the parameter list

When an argument is passed by value A) the parameter variable holds a copy of the value passed to it. B) changes can be made to the argument variable. C) the parameter variable holds the address of the argument. D) the parameter variable cannot be changed.

the parameter variable holds the address of the argument

To indicate the data type of a variable in a UML diagram you specify A) the variable name followed by a colon and the data type. B) the class name followed by the variable name followed by the data type. C) the data type followed by the variable name. D) the variable name followed by the data type.

the variable name followed by a colon and the data type

The only limitation that static methods have is A) they can only be called from static members of the class. B) they must be declared outside of the class. C) they cannot refer to nonstatic members of the class. D) they can refer only to nonstatic members of the class.

they cannot refer to nonstatic members of the class

Data hiding (which means that critical data stored inside the object is protected from code outside the object is accomplished in Java by A) using the public access specifier on the class methods. B) using the private access specifier on the class fields. C) using the private access specifier on the class definition. D) using the private access specifier on the class methods.

using the private access specifier on the class fields

The "has a" relationship is sometimes called a(n) _____ because one object is part of a greater whole. A) mutual relationship B) whole-part relationship C) enterprise D) possession 38)

whole-part

If object1 and object2 are objects of the same class, to make object2 a copy of object1 A) write a method for the class that will make a field by field copy of object1 data members into object2 data members. B) use an assignment statement to make object2 a copy of object1. C) use the default constructor to create object2 with object1 data members. D) use the copy method that is a part of the Java API

write a method for the class that will make a field by field copy of object1 data members into object2 data members

If the following is from the method section of a UML diagram, which of the statements shown is true? + equals(object2:Stock) : boolean A) This is a private method that returns a boolean value. B) This is a private method that receives two objects from the Stock class and returns a boolean value. C) This is a public method that accepts a Stock object as its argument and returns a boolean value. D) This is a public method that returns a reference to a String object.

This is a public method that accepts a Stock object as its argument and returns a boolean value.

A class's responsibilities include A) the things a class is responsible for doing. B) the things a class is responsible for knowing. C) both of these. D) neither of these.

both of these

Given the following method header, what will be returned from the method? public Rectangle getRectangle() A) the address of an object of the Rectangle class B) an object that is contained in the class Rectangle C) a null value D) the values stored in the data members of the Rectangle object

the address of an object of the Rectangle class

Which of the following can you use to compare two enum data values? A) the equals and compareTo methods B) the ordinal method C) the ==, >, and < operators D) the moreThan, lessThan, and equalsTo methods

the equals and compareTo methods

_____ is the term for the relationship created by object aggregation. A) One-to-many B) Inner class C) "Has a" D) "Is a"

"Has a"

What type of relationship exists between two objects when one object is a specialized version of another object? A) "contains a" B) "is a" C) "has a" D) "consists of"

"is a"

The control that displays a list of items and allows the user to select an item from the list is the control. A) SelectionList B) List C) ArrayList D) ListView

D) ListView

The catch clause A) contains code to gracefully handle the exception type listed in the parameter list. B) starts with the word catch followed by a parameter list in parentheses containing an ExceptionType parameter variable. C) follows the try clause. D) The catch clause does all of these.

D) The catch clause does all of these.

What does the following code do, assuming there is a variable that references a Scene object? myScene.getStylesheets().add("sceneStyles.css"); A) It adds a stylesheet named sceneStyles to Scene. B) The getStylesheets method gets sceneStyles.css and adds it to the to the myScene object. C) It adds a stylesheet named myScene to Scene. D) The getStylesheets method returns an object containing the scene's collection of stylesheets and that object's add method adds sceneStyles.css to the collection.

D) The getStylesheets method returns an object containing the scene's collection of stylesheets and that object's add method adds sceneStyles.css to the collection.

What will be the result of the following statements? FileInputStream fstream = new FileInputStream("Input.dat"); DataInputStream inFile = new DataInputStream(fstream); A) The inFile variable will reference an object that is able to write binary data to the Input.dat file. B) The inFile variable will reference an object that is able to read random access data from the Input.dat file. C) The inFile variable will reference an object that is able to read text data from the Input.dat file. D) The inFile variable will reference an object that is able to read binary data from the Input.dat file.

D) The inFile variable will reference an object that is able to read binary data from the Input.dat file.

Assuming three ImageView objects named puppy, kitten, and bunny have been created, what does the following statement do? HBox hbox = new HBox(5, puppy, kitten, bunny); A) The number 5 refers to the number of ImageView objects so there will be two empty spots for two more ImageView objects. B) The statement does nothing; it contains an error. C) The controls will be displayed vertically with five pixels between them. D) There will be five pixels of space between the controls horizontally in the container.

D) There will be five pixels of space between the controls horizontally in the container.

A class that is defined inside another class is called a(n) A) enumerated class. B) helper class. C) nested class. D) inner class.

inner class

Another term for an object of a class is a(n) A) member. B) method. C) access specifier. D) instance.

instance

To get the name of a calling enum constant A) simply use the enum constant in the statement. B) use the ordinal method. C) use the toString method. D) use the displayName method.

use the toString method

____ occurs when method A calls method B which in turn calls method A. A) Indirect recursion B) Dynamic recursion C) Linear recursion D) Direct recursion

A) Indirect recursion

The following catch clause catch (Exception e) A) can handle all exceptions that are instances of the Exception class but not its subclasses. B) can handle all exceptions that are instances of the Exception class or one of its subclasses. C) causes a compiler error. D) can handle all throwable objects by using a polymorphic reference for the parameter.

B) can handle all exceptions that are instances of the Exception class or one of its subclasses.

If ClassC is derived from ClassB which is derived from ClassA, this would be an example of A) cascading classes. B) linear inheritance. C) a chain of inheritance. D) multiple interfaces.

C) a chain of inheritance

Which of the following import statements is required in order to create a BorderPane layout container? A) import javafx.scene.layout.Box; B) import javafx.scene.layout; C) import javafx.scene.layout.BorderPane; D) import javafx.layout.scene.BorderPane;

C) import javafx.scene.layout.BorderPane;

Beginning with Java7, you can use ___ to reduce a lot of duplicated code in a try statement needs to catch multiple exceptions, but performs the same operation for each one. A) catchAll B) catch templates C) multi-catch D) multi-try

C) multi-catch

In order to leave 15 pixels of space in an HBox container, use which of the following statements? A) myhbox.setPadding.Insets(15); B) myhbox.setPadding(15); C) myhbox.setPadding(new Insets(15)); D) myhbox = setPadding(15);

C) myhbox.setPadding(new Insets(15));

A subclass can directly access A) all members of the superclass. B) only public and private members of the superclass. C) only public and protected members of the superclass. D) only protected and private members of the superclass.

C) only public and protected members of the superclass.

Which of the following statements correctly specifies two interfaces? A) public class ClassA implements Interface1 | Interface2 B) public class ClassA implements [Interface1, Interface2] C) public class ClassA implements Interface1, Interface2 D) public class ClassA implements (Interface1, Interface2)

C) public class ClassA implements Interface1, Interface2

The process of connecting an event handler object to a control is called the event handler. A) passing B) rendering C) registering D) applying

C) registering

Which CSS type selector corresponds with the TextField JavaFX class? A) text-area B) text-box C) text-field D) text

C) text-field

Which of the following is not a way a user can interact with a computer? A) console interface B) GUI C) command line D) All of these are ways a user can interact with a computer.

D) All of these are ways a user can interact with a computer.

Which of the following will create a CheckBox that displays pizza and shows up as selected? A) CheckBox checkOne = new CheckBox("pizza"); CheckBox.setSelected(false); B) CheckBox checkOne("pizza") = setSelected(true); C) CheckBox checkOne.setSelected(true) = "pizza"; D) CheckBox checkOne = new CheckBox("pizza"); checkOne.setSelected(true);

D) CheckBox checkOne = new CheckBox("pizza"); checkOne.setSelected(true);

In a catch statement, what does the following code do? System.out.println(e.getMessage()); A) It overrides the toString method. B) It prints the stack trace. C) It prints the code that caused the exception. D) It prints the error message for an exception.

D) It prints the error message for an exception.

For the following code, which statement is not true? public class Sphere { private double radius; public double x; private double y; private double z; } A) The x field is available to code that is written outside the Sphere class. B) The radius, x, y, and z fields are members of the Sphere class. C) The radius field is not available to code written outside the Sphere class. D) The z field is available to code written outside the Sphere class.

D) The z field is available to code written outside the Sphere class.

Which of the following statements declares Salaried as a subclass of PayType? A) public class Salaried derivedFrom(PayType) B) public class Salaried implements PayType C) public class PayType derives Salaried D) public class Salaried extends PayType

D) public class Salaried extends PayType

If a BorderPane region does not contain anything, A) the region will appear gray by default. B) an error will occur. C) content from an adjacent region will be duplicated to appear in the empty region. D) the region will not appear in the GUI.

D) the region will not appear in the GUI.

Given the following declaration: enum Tree ( OAK, MAPLE, PINE ) What is the fully-qualified name of the PINE enum constant? A) Tree.PINE B) enum.PINE C) enum.Tree.PINE D) PINE

Tree.PINE

In ____, inheritance is shown with a line that has an open arrowhead at one end that points to the superclass. A) a UML diagram B) a CRC card C) a hierarchy chart D) pseudocode

a UML diagram

You cannot use the fully-qualified name of an enum constant for A) an argument to a method. B) a boolean expression. C) a case expression. D) Any of these

a case expression

A protected member of a class may be directly accessed by A) methods in the same package. B) methods of the same class. C) methods of a subclass. D) any of these.

any of these

One or more objects may be created from a(n) A) class. B) field. C) instance. D) method. 4 5

class

The key word new A) creates a new Java byte code file. B) creates a new variable in memory. C) creates a new class. D) creates an object in memory.

creates an object in memory

It is common practice in object-oriented programming to make all of a class's A) fields public. B) fields and methods public. C) fields private. D) methods private.

fields private

Overloading is A) having two or more methods with the same signature. B) writing a method that does too much processing. C) writing a program that is too large to fit in memory. D) having two or more methods with the same name but different signatures.

having two or more methods with the same name but different signatures

When you make a copy of the aggregate object and of the objects that it references, 37) A) a compiler error will occur. B) you are performing a deep copy. C) you are performing a nested copy. D) you are performing a shallow copy.

you are performing a deep copy

A file that contains raw binary data is known as a A) binary file. B) raw data file. C) serial file. D) machine file.

A) binary file.

When recursive methods directly call themselves, it is known as A) direct recursion. B) basic recursion. C) indirect recursion. D) static recursion.

A) direct recursion.

Which of the following creates a custom style class that will allow a Button control to appear with a blue background and yellow text? A) .blue-button { background-color: blue; text-fill: yellow; 151) } B) .button-color { -fx- background-color: blue; -fx- text-fill: yellow; } C) .blue-button { -fx- background: blue; -fx- text: yellow; } D) .button-color { -fx- bgcolor: blue; -fx- textfill: yellow; }

B) .button-color { -fx- background-color: blue; -fx- text-fill: yellow; }

What does the following statement do? Image puppy = new Image("file:C:\\images\terrier.jpg"); A) It creates an instance of the ImageView class with the terrier.jpg file passed to the constructor. B) It loads an image file named terrier.jpg which is found in the images folder on the user's C-drive. C) It loads an image named "images\terrier.jpg" and stores the image in the Image variable. D) Nothing; it is not possible to include a path to a file when using the Image class.

B) It loads an image file named terrier.jpg which is found in the images folder on the user's C-drive.

The class is used to create a menu bar. A) Menu B) MenuBar C) Bar D) MenuItem

B) MenuBar

To retrieve text that a user has typed into a TextField control, you call the method. A) getInput B) getText C) inputText D) getInputText

B) getText

In order to preserve an image's aspect ratio (so it does not appear stretched or distorted), you should use which of the following? Assume myView references an ImageView object. A) myView.setPreserveRatio(false); B) myView.setPreserveRatio(true); C) myView.setPreserveRatio(); D) Either A or C would work. 127)

B) myView.setPreserveRatio(true);

In a class hierarchy A) the more general classes are toward the bottom of the tree and the more specialized classes are toward the top. B) the more general classes are toward the top of the tree and the more specialized classes are toward the bottom. C) the more general classes are toward the right of the tree and the more specialized classes are toward the left. D) the more general classes are toward the left of the tree and the more specialized classes are toward the right.

B) the more general classes are toward the top of the tree and the more specialized classes are toward the bottom.

A(n) _____ contains one or more statements that are executed and can potentially throw an exception. A) error block B) try block C) exception block D) catch block

B) try block

In Java there are two categories of exceptions which are A) critical and nominal. B) unchecked and checked. C) static and dynamic. D) runtime and compile-time.

B) unchecked and checked.

Which of the statements below give an alternative way to write the following: FileInputStream fstream = new FileInputStream("info.dat"); DataInputStream inputFile = new DataInputStream(fstream); A) FileInputStream fstream = new DataInputStream("info.txt"); B) FileInputStream inputFile = new FileInputStream(new DataInputStream("info.dat")); C) DataInputStream inputFile = new DataInputStream(new FileInputStream("info.dat")); D) DataInputStream inputFile = new DataInputStream("info.txt");

C) DataInputStream inputFile = new DataInputStream(new FileInputStream("info.dat"));

On a Web page, the specifies what information to display and the specifies how that information should be displayed. A) code, CSS B) CSS, HTML C) HTML, CSS D) HTML, JavaFX

C) HTML, CSS

In a UML diagram you show a realization relationship by connecting a class and an interface with a A) line with an open arrowhead at one end. B) line with an open diamond at one end. C) dashed line. D) dashed line with an open arrowhead at one end.

D) dashed line with an open arrowhead at one end.

A(n) _____ is an object that is generated in memory as the result of an error or an unexpected event. A) error message B) exception handler C) default exception handler D) exception

D) exception

To build a menu system you must A) create the Menu objects and register an event handler for each menu item object. B) Add the MenuBar object to the scene graph. C) create a MenuBar object. D) All of these are necessary steps.

D) All of these are necessary steps.

To change the alignment of an HBox you call the A) Pos method. B) Alignment method. C) PreferredSize method. D) setAlignment method.

D) setAlignment method

What method do you call to register an event handler with a Button control? A) setOnClick B) onClickAction C) setAction D) setOnAction

D) setOnAction

In CSS, selector names that begin with a period are called selectors. A) object B) class C) node D) type

D) type

The JVM periodically performs the _ process to remove unreferenced objects from memory. A) system restore B) garbage collection C) memory sweeping D) memory shuffling

garbage collection

Which of the following is not involved in identifying the classes to be used when developing an object-oriented application? A) Refine the list of nouns to include only those relevant to the problem. B) Identify all the nouns. C) Describe the problem domain. D) Write the code.

write the code

To write data to a binary file, you create objects from which of the following classes? A) FileOutputStream and DataOutputStream B) File and PrintWriter C) BinaryFileWriter and BinaryDataWriter D) File and Scanner

A) FileOutputStream and DataOutputStream

If a subclass constructor does not explicitly call a superclass constructor, A) Java will automatically call the superclass's default constructor just before the code in the subclass's constructor executes. B) the superclass's fields will be set to the default values for their data types. C) it must include the code necessary to initialize the superclass fields. D) Java will automatically call the superclass's default constructor immediately after the code in the subclass's constructor executes.

A) Java will automatically call the superclass's default constructor just before the code in the subclass's constructor executes.

In the following statement, which is the interface? public class ClassA extends ClassB implements ClassC A) ClassA B) ClassB C) ClassC D) All are interfaces.

C) Class C

The type of control normally used when you want the user to only be allowed to select one option from several possible options is the A) Button. B) CheckBox. C) RadioButton. D) Any of these

C) RadioButton.

Which of the following statements creates a Slider with a range of 1 to 20 with a starting value of 1? A) Slider slider = new Slider(0, 20, 1); B) Slider slider = new Slider(1.0, 20); C) Slider slider = new Slider(1.0, 20.0, 1.0); D) Slider slider = new slider(0.0, 20.0, 1.0); 156) 157)

C) Slider slider = new Slider(1.0, 20.0, 1.0);

The RandomAccessFile class treats a file as a stream of A) characters. B) integers. C) bytes. D) data.

C) bytes

If you do not provide initialization values for a class's numeric fields, they will A) be automatically initialized to 0. B) contain an unknown value. C) cause a runtime error. D) cause a compiler error.

be automatically initialized to zero

A declaration for an enumerated type begins with the key word. A) enum B) enumerated C) ENUM D) enum type

enum

Of the following, which would be considered the no-arg constructor for the Rectangle class? A) public Rectangle() B) public Rectangle(int len, int width) C) public Rectangle(double len, double width) D) public Rectangle(length, width)

public Rectangle()

UML diagrams do not contain A) object names. B) methods. C) fields. D) class names. 3

object names

A group of related classes is called a(n) A) archive. B) attachment. C) collection. D) package.

package

To replace a ListView control's existing items with a new list of items, use the method. A) getItems.addAll() B) getItems.setAll() C) getItems().setAll() D) getItems().addAll() 24

C) getItems().setAll()

To create a TextField control, you use the ______ class which is in the ____ package. A) TextField, javafx.text.control B) TextField, javafx.textfield C) TextField, javafx.scene.control D) TextBox, javafx.scene.control

C) TextField, javafx.scene.control

To use recursion for a binary search, what is required before the search can proceed? A) The array can only include numerical values. B) The array must include only integers. C) The array must be sorted. D) All of these are required.

C) The array must be sorted.

If the data.dat file does not exist, what will happen when the following statement is executed? RandomAccessFile randomFile = new RandomAccessFile("data.dat", "rw"); A) A compiler error will occur. B) An IOException will be thrown. C) The file, data.dat, will be created. D) A FileNotFoundException will be thrown.

C) The file, data.dat, will be created

What happens if a program does not handle an unchecked exception? A) A compiler error will occur. B) This isn't possible; the program must handle the exception. C) The program is halted and the default exception handler handles the exception. D) The exception is ignored.

C) The program is halted and the default exception handler handles the exception

For the following code, which statement is not true? public class Circle { private double radius; public double x; private double y; } A) The radius, x, and y fields are members of the Circle class. B) The radius field is not available to code written outside the Circle class. C) The x field is available to code that is written outside the Circle class. D) The y field is available to code written outside the Circle class.

D) The y field is available to code written outside the Circle class.

A static field is created by placing the key word static A) after the field name. B) after the access specifier and the field's data type. C) in brackets, before the field's data type. D) after the access specifier and before the field's data type.

after the access specifier and before the field's data type

All methods specified by an interface are A) static. B) protected. C) public. D) private.

c) public

Assume the following declaration exists: enum Tree ( OAK, MAPLE, PINE ) What will the following code display? System.out.println(Tree.OAK); A) 1 B) 0 C) OAK D) Tree.OAK

OAK

In order for an object to be serialized, the class must implement the interface. A) Serializable B) Writeable C) Serial D) ObjectOutputStream

A) Serializable

If you have two RadioButtons (dogRadio and catRadio), how should you code them to create a mutually exclusive relationship? A) ToggleGroup radioGroup = new ToggleGroup(); dogRadio.setToggleGroup(radioGroup); catRadio.setToggleGroup(radioGroup): B) ToggleGroup dogRadio = new ToggleGroup(); ToggleGroup catRadio = new ToggleGroup(); C) ToggleGroup radioGroup = new radioGroup(); dogRadio.setToggle(radioGroup); catRadio.setToggle(radioGroup): D) dogRadio.setToggleGroup(); catRadio.setToggleGroup():

A) ToggleGroup radioGroup = new ToggleGroup(); dogRadio.setToggleGroup(radioGroup); catRadio.setToggleGroup(radioGroup):

When an "is a" relationship exists between objects, the specialized object has A) all of the characteristics of the general object plus additional characteristics. B) some, but not all, of the characteristics of the general object. C) none of the characteristics of the general object. D) some of the characteristics of the general class, but not all, plus additional characteristics.

A) all of the characteristics of the general object plus additional characteristics.

A(n) ____ is a section of code that gracefully responds to exceptions when they are thrown. A) exception handler B) thrown class C) default exception handler D) exception

A) exception handler

When a method is declared with the ___ modifier, it cannot be overridden in a subclass. A) final B) super C) public D) void

A) final

In the following code that uses recursion to find the factorial of a number, what is the base case? private static int factorial(int n) { if (n == 0) return 1; else return n * factorial(n - 1); } A) if (n == 0) return 1; B) else return n * factorial(n - 1); C) factorial(int n) D) Cannot tell from this code 28

A) if (n == 0) return 1;

Which of the following is the operator used to determine whether an object is an instance of a particular class? A) instanceOf B) equals C) >> D) isa 81)

A) instanceOf

The actions performed by the JVM that take place with each method call are sometimes referred to as A) overhead. B) overflow. C) allocation. D) retention.

A) overhead.

Classes that inherit from the Error class are for exceptions that are thrown when A) an IOException occurs, and the application program should not try to handle them. B) an IOException occurs, and the application program should try to handle them. C) a critical error occurs, and the application program should try to handle them. D) a critical error occurs, and the application program should not try to handle them.

D) a critical error occurs, and the application program should not try to handle them.

If a method does not handle a possible checked exception, what must the method have? A) a finally clause in its header B) a catch clause in its header C) a try clause in its header D) a throws clause in its header

D) a throws clause in its header

An exception object's default error message can be retrieved using the method. A) getErrorMessage B) getDefaultErrorMessage C) getDefaultMessage D) getMessage

D) getMessage

Which of the following statements will allow a user to type input into a field of a ComboBox named myComboBox? A) myComboBox = ComboBox.setEditable(true); B) ComboBox.setEditable(myComboBox); C) ComboBox.setEditable; D) myComboBox.setEditable(true);

D) myComboBox.setEditable(true);

What does the following UML diagram entry mean? + setHeight(h : double) : void A) a public field called Height that is a double data type B) a public method with a parameter of data type double that does not return a value C) a private method with no parameters that returns a double data type D) a private field called setHeight that is a double data type

a public method with a parameter of data type double that does not return a value

When a method's type is an object, what is actually returned by the calling program? A) a reference to an object of that class B) only the values in the object that the method accessed C) a null reference D) an object of that class

a reference to an object of that class

A constructor A) always accepts two arguments. B) always has a private access specifier. C) has the return type of void. D) has the same name as the class.

has the same name as the class

Which is the key word used to import a class? A) assume B) import C) use D) link

import

You should not define a class that is dependent on the values of other class fields A) because it should be defined in another class. B) in order to keep it current. C) in order to avoid having stale data. D) because it is redundant.

in order to avoid having stale data

In object-oriented programming, ___ allows you to extend the capabilities of a class by creating another class that is a specialized version of it. A) prototyping B) inheritance C) data hiding D) code reusability

inheritance

When the this variable is used to call a constructor A) it must be the first statement in the constructor making the call. B) it must be the last statement in the constructor making the call. C) it can be anywhere in the constructor making the call. D) None of these. You cannot use the this variable in a constructor call.

it must be the first statement in the constructor making the call

A method A) may not have only one parameter variable. B) must have at least two parameter variables. C) may have zero or more parameters. D) never has parameter variables.

may have zero or more parameters

When an exception is thrown A) it must be handled by the program or by the default exception handler. B) the program terminates even if the exception is handled. C) it must always be handled by the method that throws it. D) it may be ignored.

A) it must be handled by the program or by the default exception handler

In the hexadecimal color value #CCAA99, the CC refers to which color component? A) red B) green C) blue D) yellow 23

A) red

The Application class's ____ method is the main entry point for a JavaFX application. A) start B) addWindow C) mainFX D) init

A) start

In a recursive program, the number of times a method calls itself is known as A) the depth of recursion. B) the cyclic identity. C) the method heap. D) the call count. 26 27

A) the depth of recursion.

Which of the following import statements is required in order to write an event handler class? A) import javafx.EventHandler.event; B) import javafx.event.EventHandler; C) import javafx.event.ActionEvent; D) import javafx.EventHandler;

B) import javafx.event.EventHandler;

To display an image in a JavaFX application you must A) include both the setImage and the ViewImage classes. B) include both the Image and the ImageView classes. C) include either the setImage or the ViewImage class. D) include either the Image or the ImageView class.

B) include both the Image and the ImageView classes.

Given the following code that uses recursion to find the factorial of a number, how many times will the else clause be executed if n = 5? private static int factorial(int n) { if (n == 0) return 1; else return n * factorial(n - 1);} A) 4 B) 3 C) 5 D) 6

C) 5

A method is called from the main method for the first time. It then calls itself seven times. What is the depth of recursion? A) 1 B) 8 C) 7 D) 6 179)

C) 7

An action that takes place while a program is running is a(n) A) event object. B) event handler. C) event. D) event source.

C) event.

Which of the following statements correctly adds a label to the first row and second column of a GridPane object? A) gridpane.add(myLabel, 2, 1); B) gridpane.add(myLabel, 1, 0); C) gridpane.add(myLabel, 0, 1); D) gridpane.add(myLabel, 1, 2);

C) gridpane.add(myLabel, 0, 1);

In the following code that uses recursion to find the greatest common divisor of a number, what is the base case? public static int gcd(int x, int y) { if (x % y == 0) return y; else return gcd(y, x % y); } A) else return gcd(y, x % y); B) gcd(int x, int) C) if (x % y == 0) return y; D) Cannot tell from this code

C) if (x % y == 0) return y;

Which of the following problems can be solved recursively? A) Towers of Hanoi B) greatest common denominator C) binary search D) All of these

D) All of these

What is the following statement an example of? import java.util.*; A) a wildcard import statement B) an explicit import statement C) an unconditional import statement D) a conditional import statement

a wildcard import statement

When a method in the __ class returns a reference to a field object, it should return a reference to a copy of the field object to prevent security holes. A) String B) aggregate C) inner D) nested

aggregate

When you write an enumerated type declaration, you A) do not enclose the enum constants in quotation marks. B) should use the standard convention of writing the enum constants in uppercase. C) are actually creating a special kind of class. D) All of these

all of these

Which of the following shows the inheritance relationships among classes in a manner similar to that of a family tree? A) CRC card B) flowchart C) class hierarchy D) UML diagram

class hierarchy

When a class implements an interface, an inheritance relationship known as __ inheritance is established. A) abstract B) realized C) interface D) implemented

interface


संबंधित स्टडी सेट्स

AP Psychology Chapter 2-7 Exam Review

View Set

HTML: Defining each Topic (w3schools.com)

View Set

Chapter 52 skin and topical drugs

View Set

Grammar Hesi a2 nursehub test #1

View Set

APCS Final Semester 1 Test Review

View Set

Art since 1945 (Midterm Images Study) (Last Names Only)

View Set