INSY-4306 Final | CH 14,16,17,23

Ace your homework & exams now with Quizwiz!

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. .button-color { - fx- background-color: blue; -fx- text-fill: yellow;} b. .button-color { -fx- bgcolor: blue; -fx- textfill: yellow;} c. .blue-button { background-color: blue; text-fill: yellow;} d. .blue-button { -fx- background: blue; -fx- text: yellow;}

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

Which SQL keyword is required in every query? a. FROM. b. WHERE. c. ORDER BY. d. LIKE.

a. FROM.

The __________ layout container arranges its contents with columns and rows. a. GridLayout b. GridPane c. Grid d. CellManager

a. GridLayout

This keyword is used to add a row to a table. a. INSERT. b. ADD. c. UPDATE. d. CREATE

a. INSERT.

What does a primary key do? a. Identifies each row of a table. b. Selects a number of rows from a database. c. Stores a bunch of related data. d. None of the above.

a. Identifies each row of a table.

Which of the following statements is false? a. If an operation requires the executing thread to hold a lock while the operation is performed, a thread must relase the lock before proceeding with the operation. Other threads attempting to perform an operation that requires the same lock will be blocked until the first thread releases the lock, at which point the blocked threads may attempt to acquire the lock and proceed with the operation. b. To specify that a thread must hold a monitor lock to execute a block of code, the code should be placed in a synchronized statement. c. Code in a synchronized statement is said to be guarded by the monitor lock; a thread must acquire the lock to execute the guarded statements. d. The monitor allows only one thread at a time to execute statements within synchronized statements that lock on the same object, as only one thread at a time can hold the monitor lock. The synchronized statements are declared using the synchronized keyword.

a. If an operation requires the executing thread to hold a lock while the operation is performed, a thread must release the lock before proceeding with the operation. Other threads attempting to perform an operation that requires the same lock will be blocked until the first thread releases the lock, at which point the blocked threads may attempt to acquire the lock and proceed with the operation. Actually, if an operation requires the executing thread to hold a lock while the operation is performed, a thread must acquire the lock before proceeding with the operation. Other threads attempting to perform an operation that requires the same lock will be blocked until the first thread releases the lock, at which point the blocked threads may attempt to acquire the lock and proceed with the operation

The __________ class is used to create a menu bar. a. MenuBar b. Menu c. MenuItem d. Bar

a. MenuBar

The result of a query can be sorted by using the optional _________ clause. a. ORDER BY b. ORDER c. SORT BY d. SORT

a. ORDER BY

Consider the Java segment: String line1 = new String("c = 1 + 2 + 3"); StringTokenizer tok = new StringTokenizer(line1, delimArg); For the String line1 to have 4 tokens, delimArg should be: a. String delimArg = "+="; b. String delimArg = "123" c. String delimArg = "c+"; d. String delimArg = " ";

a. String delimArg = "+=";

Which of the following statements creates an empty TextArea? a. TextArea textArea = new TextArea(); b. TextArea textArea = new TextArea(" "); c. TextArea = new textArea(); d. TextArea textArea = new TextArea.textArea("");

a. TextArea textArea = new TextArea();

Which of the following statements is true? a. The throw statement is used to throw an exception. b. The throw statement is used to specify that a method will throw an exception. c. The throw statement is used to access an exception parameter. d. All of the above.

a. The throw statement is used to throw an exception.

Which of the following statements is false? a. Thread scheduling is platform independent. b. One simple thread-scheduler implementation keeps the highest-priority thread running at all times and, if there's more than one highest-priority thread, ensures that all such threads execute for a quantum each in round-robin fashion. c. The round-robin process for all highest-priority threads continues until all threads run to completion. d. Most programmers who use Java multithreading will not be concerned with setting and adjusting thread priorities

a. Thread scheduling is platform independent. Actually, thread scheduling is platform dependent—the behavior of a multithreaded program could vary across different Java implementations

After a finally block has finished executing (and there are no exceptions to be handled), ________. a. control proceeds to the first statement after the finally block. b. control returns to the throw point. c. the application exits. d. control proceeds to the first statement after the last catch block.

a. control proceeds to the first statement after the finally block.

Recursion is often less efficient than iteration because ________. a. it can cause an explosion of method calls. b. it is not as intuitive. c. recursive methods are harder to debug. d. recursive methods take longer to program.

a. it can cause an explosion of method calls.

When using Java's built-in monitors, every object has a(n) ________ or a(n) ________ that the monitor ensures is held by a maximum of only one thread at any time. a. monitor lock, intrinsic lock b. built-in lock, free lock c. mutual exlcusion lock, synchronization lock d. None of the above

a. monitor lock, intrinsic lock

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. only part of the image will be displayed b. the image will only occupy part of the window c. the scene will automatically be resized to fit the image d. the image will automatically be resized to fit the window

a. only part of the image will be displayed

A ________ is a column (or set of columns) which have a unique value that cannot be duplicated in other rows? a. primary key. b. query. c. SQL statement. d. lookup value

a. primary key.

The BlockingQueue interface declares which two methods for blocked adding and blocked removing of elements from a circular buffer? a. put and take. b. add and remove. c. push and pop. d. place and get.

a. put and take.

With timeslicing, each thread is given a limited amount of time, called a __________, to execute on a processor. a. quantum b. burst c. time allocation d. scheduling interval

a. quantum

A waiting thread transitions back to the ________ state only when another thread notifies it to continue executing. a. runnable b. terminated c. new d. blocked

a. runnable

The ArrayBlockingQueue method ________ returns the number of elements currently in the ArrayBlockingQueue? a. size. b. length. c. getSize. d. getLength.

a. size.

When a __________ method or block is running on an object, the object is locked so no other such method can run on that object at the same time. a. synchronized b. shared c. thread d. Writeable

a. synchronized

All of the following are true for both recursion and iteration except ________. a. they have a base case. b. they can cause infinite loops or infinite recursion. c. they are based on a control statement. d. both gradually approach termination.

a. they have a base case.

Which symbol indicates that all columns should be retrieved? a. ? b. * c. + d. /

b. *

Which of the following statements is false? a. Lambda expressions can be used anywhere functional interfaces are expected. b. A lambda consists of a parameter list followed by the arrow token and a body, as in: [parameterList] -> {statements} c.Method references are specialized shorthand forms of lambdas. d. Each of the above statements is true.

b. A lambda consists of a parameter list followed by the arrow token and a body, as in: [parameterList] -> {statements} Actually, a lambda consists of a parameter list followed by the arrow token and a body, as in: (parameterList) -> {statements}

Which of the following statements about the Graphics object is true? A. The Graphics object is an argument to class Component's repaint method. B. The Graphics object is instantiated by the user. C. The Graphics object is the argument to a lightweight GUI component's paintComponent method. D. The Graphics class is abstract. E. The Graphics object manages a graphics context. a. A, C, E. b. C, D, E. c. A, B, D, E. d. All are true.

b. C, D, E.

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

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

Which statement is false? a. A ListIterator accesses the elements of a List. b. Class ArrayList is a fixed-size array. c. A LinkedList is a linked list implementation of a List. d. ArrayLists execute faster than Vectors because they are not thread safe.

b. Class ArrayList is a fixed-size array. Actually, ArrayList is a dynamically resizable array-like data structure

Which of the following statements is false? a. Java makes concurrency available to you through the language and APIs. b. Concurrency is a subset of parallelism. c. Today's multi-core computers have multiple processors that can perform tasks in parallel. d. Java programs can have multiple threads of execution, where each thread has its own method-call stack and program counter, allowing it to execute concurrently with other threads. This capability is called multithreading.

b. Concurrency is a subset of parallelism. Actually, parallelism is a subset of concurrency.

An ExecutorService object is created by calling a static method of which class? a. Executor. b. Executors. c. ExecutorService. d. Thread

b. Executors

The __________ layout container arranges the contents into cells, similar to a spreadsheet. a. GRID b. GridPane c. GridPaneObj d. CellPane

b. GridPane

Which statement is false? a. Java does not guarantee which item will be found first when a binarySearch is performed on a List containing multiple elements equivalent to the search key. b. If the search key is found, method binarySearch returns the List index (position relative to 1) of the element containing the search key. c. The binary search algorithm is fast. d. Method binarySearch takes a List as the first argument

b. If the search key is found, method binarySearch returns the List index (position relative to 1) of the element containing the search key. Actually, it returns the position relative to zero

Which of the following performs a boxing conversion? a. int x = 7; b. Integer x = 7; c. Neither of the above. d. Both of the above.

b. Integer x = 7;

Which of the following is not true of ExecutorService? a. It is a subinterface of Executor. b. It is an object that can be run in a separate thread. c. It declares method shutdown. d. It manages a group of threads.

b. It is an object that can be run in a separate thread.

Java programs communicate with databases using what API? a. DBMS. b. JDBC. c. RDBMS. d. Database

b. JDBC.

Any time a user presses a key, a __________ event occurs. a. KEY_TYPED b. KEY_PRESSED c. KEY_RELEASED d. KEY_EVENT

b. KEY_PRESSED

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. RadioButton c. CheckBox d. Any of these

b. RadioButton

Which class creates an animation in which a node rotates? a. Rotate b. RotateTransition c. NodeRotation d. NodeRotate

b. RotateTransition

Which of the following statements is false? a. A runnable thread can enter the timed waiting state for a specified interval of time. It transitions back to the runnable state when that time interval expires or when the event it's waiting for occurs. b. Timed waiting threads and waiting threads can use a processor, if one is available. c. A runnable thread can transition to the timed waiting state if it provides an optional wait interval when it's waiting for another thread to perform a task. Such a thread returns to the runnable state when it's notified by another thread or when the timed interval expires—whichever comes first. d. Another way to place a thread in the timed waiting state is to put a runnable thread to sleep—a sleeping thread remains in the timed waiting state for a designated period of time (called a sleep interval), after which it returns to the runnable state

b. Timed waiting threads and waiting threads can use a processor, if one is available. Actually, timed waiting threads and waiting threads cannot use a processor, even if one is available.

Which of the following statements is false? a. Most operating systems support timeslicing, which enables threads of equal priority to share a processor. b. Without timeslicing, each thread in a set of equal-priority threads runs to completion before other threads of equal priority get a chance to execute. c. With timeslicing, even if a thread has not finished executing when its quantum expires, the processor is taken away from the thread and given to the next thread of equal priority, if one is available. d. An operating system's thread scheduler determines which thread runs next.

b. Without timeslicing, each thread in a set of equal-priority threads runs to completion before other threads of equal priority get a chance to execute. Actually, without timeslicing, each thread in a set of equal-priority threads runs to completion (unless it leaves the runnable state and enters the waiting or timed waiting state, or gets interrupted by a higher-priority thread) before other threads of equal priority get a chance to execute.

The String method substring returns ________. a. a char b. a String c. void d. a char[]

b. a String.

In an UPDATE statement, the SET keyword is followed by _________. a. a comma-separated list of column value-name pairs in the format value = columnName b. a comma-separated list of column name-value pairs in the format columnName = value c. a semicolon-separated list of column value-name pairs in the format value = columnName d. a semicolon-separated list of column name-value pairs in the format columnName = value

b. a comma-separated list of column name-value pairs in the format columnName = value

The recursion step should: a. check for the base case. b. call a fresh copy of the recursive method to work on a smaller problem. c. make two calls to the recursive method. d. iterate until it reaches a termination condition.

b. call a fresh copy of the recursive method to work on a smaller problem.

Two tasks that are operating ________ are both making progress at once. a.sequentially b.concurrently c.iteratively d.Recursively

b. concurrently

PreparedStatement method ________ returns a ResultSet. a. executeUpdate b. executeQuery c. execute d. None of the above.

b. executeQuery

Which of the following import statements must be used in order to use the Color class? a. import.javafx.scene.Paint.color; b. import.javafx.scene.paint.Color; c. import.javafx.paint.color; d. import.javafx.scene.Color;

b. import.javafx.scene.paint.Color;

Two tasks that are operating ________ are executing simultaneously. a. concurrently b. in parallel c. sequentially d. iteratively

b. in parallel

An anonymous String ________. a. has no value b. is a string literal c. can be changed d. none of the above

b. is a string literal.

The main method executes in the ________ thread of execution. a. starting b. main c. local d. None of the above.

b. main

When an event takes place, the control responsible for the event creates an event __________. a. source b. object c. handler d. firing

b. object

Consider the Java code segment below: Polygon poly2 = new Polygon(); poly2.addPoint(100, 30); poly2.addPoint(100, 130); Which of the following will create a polygon that is a square? a. poly2.addPoint(100, 60); poly2.addPoint(100, 130); b. poly2.addPoint(200, 130); poly2.addPoint(200, 30); c. poly2.addPoint(200, 60); poly2.addPoint(200, 130); d. poly2.addPoint(100, 130); poly2.addPoint(100, 230);

b. poly2.addPoint(200, 130); poly2.addPoint(200, 30);

In a producer/consumer relationship, the ________ portion of an application generates data and stores it in a shared object, and the ________ portion of an application reads data from the shared object. a. consumer, producer b. producer, consumer c. outputter, inputter d. None of the above.

b. producer, consumer

The process of connecting an event handler object to a control is called __________ the event handler. a. passing b. registering c. applying d. rendering

b. registering

If the catch-or-declare requirement for a checked exception is not satisfied ________. a. the compiler will issue an error message indicating that the exception must be caught. b. the compiler will issue an error message indicating that the exception must be caught or declared. c. a stack trace will be displayed indicating the exception that has occurred and where it occurred. d. a stack trace will be displayed, along with a message indicating that the exception must be caught.

b. the compiler will issue an error message indicating that the exception must be caught or declared.

Given a window that is 640 (width) by 480 (height), which of the following represents the lowest position on the left side? a. (639, 0) b. (0, 639) c. (0, 479) d. (479, 0)

c. (0, 479)

Given the following declaration: StringBuilder buf = new StringBuilder(); What is the capacity of buf? a. 0 b. 10 c. 16 d. 20

c. 16

Which of the following statements is false? a. A common way to perform synchronization is to use Java's built-in monitors. b. Every object has a monitor and a monitor lock (or intrinsic lock). c. A monitor ensures that its object's monitor lock is held by a maximum of two threads at a time. d. Monitors and monitor locks can be used to enforce mutual exclusion.

c. A monitor ensures that its object's monitor lock is held by a maximum of two threads at a time. Actually, a monitor ensures that its object's monitor lock is held by a maximum of only one thread at any time.

Which of the following properly create and initialize a Font object? A. Font f = new Font(); B. Font f = new Font("Serif", Font.Bold + Font.Italic, 19); C. Font f = new Font(Font.Bold, 20, "SansSerif"); D. Font f = new Font(20, Font.Bold, "Monospaced"); a. A and B. b. B and C. c. B. d. D.

c. B.

Which of the following statements is true? a. Ranges of characters can be represented by placing a ~ between two characters. b. [^Z] is the same as [A~Y]. c. Both "A*" and "A+" will match "AAA", but only "A*" will match an empty string. d. All of above.

c. Both "A*" and "A+" will match "AAA", but only "A*" will match an empty string.

String objects are immutable. This means they ________. a. must be initialized b. cannot be deleted c. cannot be changed d. None of the above

c. Cannot be changed.

Which statement is false? a. A collection is an object that can hold references to other objects. b. The collection interfaces declare the operations that can be performed on each type of collection. c. Collections discourage software reuse because they are non-portable. d. Collections are carefully constructed for rapid execution and efficient use of memory.

c. Collections discourage software reuse because they are non-portable. Actually, they encourage software reuse because they are portable.

Which effect class do you use to increase an image's brightness? a. Glow b. Reflection c. ColorAdjust d. SepiaTone

c. ColorAdjust

On a web page, the __________ specifies what information to display and the __________ specifies how that information should be displayed. a. HTML, JavaFX b. code, CSS c. HTML, CSS d. CSS, HTML

c. HTML, CSS

Which of the following statements is false? a. In a multithreaded application, threads can be distributed across multiple processors (if available) so that multiple tasks execute in parallel and the application can operate more efficiently. b. The JVM creates threads to run a program and for housekeeping tasks such as garbage collection. c. Multithreading can increase performance only on multi-core systems. d. The vast majority of programmers should use existing collection classes and interfaces from the concurrency APIs that manage synchronization for you

c. Multithreading can increase performance only on multi-core systems. Actually, multithreading can also increase performance on single-processor systems—when one thread cannot proceed (because, for example, it's waiting for the result of an I/O operation), another can use the processor.

Which statement is false? a. Queue is a new collection interface introduced in J2SE 5.0. b. Queue and PriorityQueue are included in the java.util package. c. PriorityQueue orders elements in increasing order, so that smallest value will be the first element removed from PriorityQueue. d. Queue extends interface Collection.

c. PriorityQueue orders elements in increasing order, so that smallest value will be the first element removed from PriorityQueue. Actually, PriorityQueue orders elements in their natural order as specified by interface Comparable

The preferred means of creating multithreaded Java applications is by implementing the ________ interface. An object of a class that implements this interface represents a task to perform. a. Thread b. Runner c. Runnable d. None of the above

c. Runnable

What exception is thrown if DriverManager method getConnection cannot connect to the database? a. DatabaseConnectionException. b. DatabaseNotFoundException. c. SQLException. d. IllegalAccessException.

c. SQLException.

Consider the String below: String r = "a toyota"; Which of the following will create the String r1 = "a TOYOTa"? a. String r1 = r.replace("toyot", TOYOT"); b. String r1 = r.replace('t','T'); r1 = r.replace('o','0'); r1 = r.replace('y','Y'); c. String r1 = r.replace('t','T').replace('o', '0').replace('y', 'Y'); d. String r1 = r.substring(2, 4).toUpperCase();

c. String r1 = r.replace('t','T').replace('o', '0').replace('y', 'Y');

The basic generic functional interface ________ in package java.util.function contains method get that takes no arguments and produces a value of type T. Often used to create a collection object in which a stream operation's results are placed. a. Consumer<T> b. Function<T,R> c. Supplier<T> d. BinaryOperator<T>

c. Supplier<T>

Which of the following statements draws the string "Love to animate!" starting at coordinates (200, 50)? a. Text myText = new myText(200, 50, "Love to animate!"); b. Text myText = new Text(50.0, 200.0, "Love to animate!"); c. Text myWords = new Text(200.0, 50.0, "Love to animate!"); d. Text Words = new Words(200, 50, "Love to animate!");

c. Text myWords = new Text(200.0, 50.0, "Love to animate!");

Which of the following statements is false? a. A finally block is placed after the last catch block. b. A finally block typically releases resources acquired in the corresponding try block. c. The finally block and try block can appear in any order. d. A finally block is optional.

c. The finally block and try block can appear in any order.

In a producer/consumer relationship with a single cell of shared memory, which of the following is true? a. The consumer must run first. b. The producer must run first. c. The producer must run first or the consumer will have to wait. d. The consumer must run first or the producer will have to wait.

c. The producer must run first or the consumer will have to wait.

What is the difference between a try block and a try statement? a. There is no difference; the terms can be used interchangeably. b. A try statement refers to the block of code following the keyword try, while the try block refers to the try keyword and the block of code following this keyword. c. The try block refers to the keyword try followed by a block of code. The try block and its corresponding catch and/or finally clauses together form a try statement. d. The try statement refers to the keyword try followed by a block of code. The try statement and its corresponding catch and/or finally clauses together form a try block.

c. The try block refers to the keyword try followed by a block of code. The try block and its corresponding catch and/or finally clauses together form a try statement.

Interface ExecutorService provides the ________ method, which returns control to its caller either when all tasks executing in the ExecutorService complete or when the specified timeout elapses. a. waitForTermination b. wait c. awaitTermination d. None of the above.

c. awaitTermination

All exception classes inherit, either directly or indirectly, from ________. a. class Error. b. class RuntimeException. c. class Throwable. d. None of the above.

c. class Throwable.

Another problem related to indefinite postponement is called ________. This occurs when a waiting thread (let's call this thread1) cannot proceed because it's waiting (either directly or indirectly) for another thread (let's call this thread2) to proceed, while simultaneously thread2 cannot proceed because it's waiting (either directly or indirectly) for thread1 to proceed. The two threads are waiting for each other, so the actions that would enable each thread to continue execution can never occur. a. impass b. standoff c. deadlock d. stalemate

c. deadlock

The Java statement: g.draw3DRect(290, 100, 90, 55, true); a. draws a rectangle that appears to be raised (the top and left edges of the rectangle are slightly darker than the rectangle). b. draws a rectangle that appears to be lowered (the bottom and right edges of the rectangle are slightly darker than the rectangle). c. draws a rectangle that appears to be raised (the bottom and right edges of the rectangle are slightly darker than the rectangle). d. draws a rectangle that appears to be lowered (the top and left edges of the rectangle are slightly darker than the rectangle).

c. draws a rectangle that appears to be raised (the bottom and right edges of the rectangle are slightly darker than the rectangle).

To retrieve text that a user has typed into a TextField control, you call the __________ method. a. inputText b. getInput c. getText d. getInputText

c. getText

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

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

For String c = "hello world"; The Java statements int i = c.indexOf('o'); int j = c.lastIndexOf('l'); will result in: a. i = 4 and j = 8. b. i = 5 and j = 8. c. i = 4 and j = 9. d. i = 5 and j = 9.

c. i = 4 and j = 9.

Recursion often is preferable to iteration because ________. a. it is faster. b. it requires less memory. c. it models the problem more logically. d. All of the above.

c. it models the problem more logically.

You can simulate atomicity by ensuring that ________. a. at least one thread carries out its operations on an object at a time b. two threads carry out their operations on an object in parallel c. only one thread carries out its operations on an object at a time d. None of the above.

c. only one thread carries out its operations on an object at a time

The collections framework algorithms are __________, i.e., each of these algorithms can operate on objects that implement specified interfaces without concern for the underlying implementations. a. stable. b. lexicographical. c. polymorphic. d. implementation dependent.

c. polymorphic.

To add padding to an HBox you can call the __________ method. a. HBoxPadding b. SetHBoxPadding c. setPadding d. setHboxPad

c. setPadding

When a higher-priority thread enters the ready state, the operating system generally preempts the currently running thread (an operation known as preemptive scheduling). Depending on the operating system, a steady influx of higher-priority threads could postpone—possibly indefinitely—the execution of lower-priority threads. such indefinite postponement is sometimes referred to more colorfully as________. a. fasting b. famine c. starvation d. malnourishment

c. starvation

A runnable thread enters the ________ state (sometimes called the dead state) when it successfully completes its task or otherwise terminates (perhaps due to an error). a. extinct b. defunct c. terminated d. aborted

c. terminated

What is the meaning of ( ) in the following lambda? () -> System.out.println("Welcome to lambdas!") a. the lambdas parameters are inferred b. the lambdas parameters are supplied by a method reference c. the lambda has an empty parameter list d. the given expression is not a valid lambda

c. the lambda has an empty parameter list

When the recursion step executes: a. this is known as indirect recursion. b. all of the computer's processes halt until the recursion step has completed executing. c. the original call to the method is still active. d. All of the above.

c. the original call to the method is still active.

To catch an exception, the code that might throw the exception must be enclosed in a ________. a. throws block. b. catch block. c. try block. d. finally block.

c. try block

How many String objects are instantiated by the following code segment (not including the literals)? String s1, output; s1 = "hello"; output = "\nThe string reversed is: " ; for (int i = s1.length() - 1; i >= 0; i--) output += s1.charAt(i) + " " ; a. 1. b. 4. c. 5. d. 7.

d. 7.

StringBuilder objects can be used in place of String objects if ________. a. the string data is not constant b. the string data size may grow c. the programs frequently perform string concatenation d. All of the above.

d. All of the above

The statement s1.startsWith("art") has the same result as which of the following? a. s1.regionMatches(0, "art", 0, 3); b. s2 = s1.getChars(0, 3); s2.equals("art"); c. s1.regionMatches(true, 0, "art", 0, 3); d. All of the above

d. All of the above

Which of the following statements about the Java 2D API is true? a. A Graphics2D object is instantiated to draw Java 2D figures. b. Class Graphics2D is a subclass of class Graphics. c. To access Graphics2D capabilities, cast the Graphics reference passed to paintComponent to a Graphics2D reference. d. All of the above are true.

d. All of the above are true.

Which of the following statements is false? a. A method reference of the form objectName::instanceMethodName is a bound instance method reference. b. A method reference of the form ClassName::staticMethodName is a static method reference. c. Collectors method joining is a collector that creates a concatenated String representation of the stream's elements, appending each element to the String separated from the previous element by the joining method's argument. d. All of the above statements are true.

d. All of the above statements are true.

Which of the following statements is false? a. You filter elements to produce a stream of intermediate results that match a predicate. b. IntStream method filter receives an object that method that takes one parameter and returns a boolean result. c. If the result of calling filter's argument is true for a given element, that element is included in the resulting stream. d. All of the above statements are true.

d. All of the above statements are true.

A recursive method _____________. a. is a method that calls itself. b. can be called directly. c. can be called indirectly through another method. d. All of the above.

d. All of the above.

To build a menu system you must __________. a. create a MenuBar object b. create the Menu objects and register an event handler for each menu item object c. Add the MenuBar object to the scene graph d. All of these are necessary steps.

d. All of these are necessary steps.

The basic generic functional interface ________ in package java.util.function contains method apply that takes two T arguments, performs an operation on them (such as a calculation) and returns a value of type T. a. Consumer<T> b. Function<T,R> c. Supplier<T> d. BinaryOperator<T>

d. BinaryOperator<T>

Which of the following statements is false? a. A runnable thread transitions to the blocked state when it attempts to perform a task that cannot be completed immediately and it must temporarily wait until that task completes. b. When a thread issues an input/output request, the operating system blocks the thread from executing until that I/O request completes—at that point, the blocked thread transitions to the runnable state, so it can resume execution. c. A blocked thread cannot use a processor, even if one is available. d. Each of the above statements is true.

d. Each of the above statements is true.

t's recommended that you do not explicitly create and use Thread objects to implement concurrency, but rather use the ________ interface. a. ExecutorService b. Runnable c. Concurrent d. Executor

d. Executor

An ________ (package java.util.stream) is a stream that manipulates int values. a. StreamOfInt b. IStream. c. IntegerStream d. IntStream

d. IntStream

Pattern matching in a SQL query is performed with which clause? a. FROM. b. WHERE. c. SELECT. d. LIKE.

d. LIKE.

Which of the following statements is false? a. Thread synchronization is necessary only for shared mutable data, i.e., data that may change during its lifetime. b. With shared immutable data that will not change, it's not possible for a thread to see old or incorrect values as a result of another thread's manipulation of that data. c. When you share immutable data across threads, declare the corresponding data fields final to indicate that the values of the variables will not change after they're initialized. This prevents accidental modification of the shared data, which could compromise thread safety. d. Labeling object references as final indicates that the referenced object is immutable.

d. Labeling object references as final indicates that the referenced object is immutable. Actually, labeling object references as final indicates that the reference will not change, but it does not guarantee that the referenced object is immutable—this depends entirely on the object's properties.

Which of the following statements about try blocks is true? a. The try block must be followed by at least one catch block. b. The try block must be followed by a finally block. c. The try block should contain statements that may process an exception. d. The try block should contain statements that may throw an exception.

d. The try block should contain statements that may throw an exception.

Which of the following statements is false? a. Every Java thread has a thread priority that helps determine the order in which threads are scheduled. b. Each new thread inherits the priority of the thread that created it. c. Informally, higher-priority threads are more important to a program and should be allocated processor time before lower-priority threads. d. Thread priorities guarantee the order in which threads execute.

d. Thread priorities guarantee the order in which threads execute. Actually, even with thread priorities, the operating system determines the order in which threads execute.

Which of the following statements is false? a. If several synchronized statements in different threads are trying to execute on an object at the same time, only one of them may be active on the object—all the other threads attempting to enter a synchronized statement on the same object are placed in the blocked state. b. When a synchronized statement finishes executing, the object's monitor lock is released and one of the blocked threads attempting to enter a synchronized statement can be allowed to acquire the lock to proceed. c. Java also allows synchronized methods. Before executing, a synchronized instance method must acquire the lock on the object that's used to call the method. d. Using a synchronized block to enforce mutual exclusion is an example of the design pattern known as the Java Exclusion Pattern.

d. Using a synchronized block to enforce mutual exclusion is an example of the design pattern known as the Java Exclusions Pattern. Actually, using a synchronized block to enforce mutual exclusion is an example of the design pattern known as the Java Monitor Pattern

Which of the following statements is false? a. Each intermediate operation results in a new stream. b. Each new stream is simply an object representing the processing steps that have been specified to that point in the pipeline. c. Chaining intermediate-operation method calls adds to the set of processing steps to perform on each stream element. The last stream object in the stream pipeline contains all the processing steps to perform on each stream element. d. When you initiate a stream pipeline with a terminal operation, the each processing step is applied for to all the stream elements before the next processing step is applied.

d. When you initiate a stream pipeline with a terminal operation, the each processing step is applied for to all the stream elements before the next processing step is applied. Actually, when you initiate a stream pipeline with a terminal operation, the intermediate operations' processing steps are applied for a given stream element before they are applied to the next stream element.

Operating systems employ a technique called ________ to prevent indefinite postponement—as a thread waits in the ready state, the operating system gradually increases the thread's priority to ensure that the thread will eventually run. a. incrementing b. prioritizing c. maturing d. aging

d. aging

A lambda expression represents a(n) ________ method—a shorthand notation for implementing a functional interface. a. functional b. unnamed c. undesignated d. Anonymous

d. anonymous

Interface Collection contains __________ operations (i.e., operations performed on the entire collection). a. aggregate. b. composite. c. integral. d. bulk.

d. bulk.

A(n) __________ is an action that takes place in an application, such as the clicking of a button. a. instance b. effect c. case d. event

d. event

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.layout.scene.BorderPane; d. import javafx.scene.layout.BorderPane;

d. import javafx.scene.layout.BorderPane;

A new thread begins its life cycle by transitioning to the __________ state. a. runnable. b. waiting. c. terminated. d. new.

d. new

Maps allocate keys to values and cannot contain duplicate keys, i.e., the key-to-value mapping is a __________ mapping. a. many-to-many. b. many-to-one. c. one-to-many. d. one-to-one.

d. one-to-one.

Collections method ___________ returns a Comparator object that orders the collection's elements in reverse order. a. rotate. b. shuffle. c. reverse. d. reverseOrder.

d. reverseOrder.

What method do you call to register an event handler with a Button control? a. setAction b. onClickAction c. setOnClick d. setOnAction

d. setOnAction

Algorithm __________ randomly orders a List's elements. a. randomShuffle. b. randomPlacement. c. fiftyTwoCardPickup. d. shuffle.

d. shuffle.

IntStream method ________ performs the count, min, max, sum and average operations in one pass of an IntStream's elements and returns the results as an IntSummaryStatistics object (package java.util). a. allStatistics. b. completeStatistics. c. entireStatistics. d. summaryStatistics

d. summaryStatistics


Related study sets

Interest Rates and Bond Valuation

View Set

Personal Training Quiz (Ch.10,11,12)

View Set

NU271 HESI Prep: Fundamentals - Issues in Nursing

View Set

Chapter 27 Face and Neck Injuries

View Set

SPL CHAPTER 7: INTRODUCTION TO COLD CHAIN

View Set

Chapter 11 - Global and International Issues

View Set

principles of real estate 1 texas unit 9

View Set

ECON 2106 - CH 12 & 13 "Final Material"

View Set