SWD Tophat Review
In what year was Java first created?
1991
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. 1) consumer, producer. 2) producer, consumer. 3) outputter, inputter. 4) None of the above.
2) producer, consumer.
Which statement is false? Normally, an applet __________. 1. is allowed to read files only on the server from which the applet was downloaded. 2. can read files on any server that can be reached over the network. 3. cannot read files on the system on which it executes. 4. has different file access rights than an application running on the same machine.
2. can read files on any server that can be reached over the network.
In a producer/consumer relationship with a single cell of shared memory, which of the following is true? 1) The consumer must run first. 2) The producer must run first. 3) The producer must run first or the consumer will have to wait. 4) The consumer must run first or the producer will have to wait.
3) The producer must run first or the consumer will have to wait.
You can simulate atomicity by ensuring that ________. 1) at least one thread carries out its operations on an object at a time. 2) two threads carry out their operations on an object in parallel. 3) only one thread carries out its operations on an object at a time. 4) None of the above.
3) only one thread carries out its operations on an object at a time.
Consider the abstract superclass below: public abstract class Foo { private int a; public int b; public Foo(int aVal, int bVal) { a = aVal; b = bVal; } public abstract int calculate(); } Question: Any concrete subclass that extends class Foo __ 1) Must implement a method called calculate. 2) Will not be able to access the instance variable a. 3) Neither (a) nor (b). 4) Both (a) and (b).
4 - Both (a) and (b).
Which of the following statements about Swing GUI components is false? a. Swing components are less portable but more flexible than the original Java GUI components from package java.awt. b. Most Swing components are written completely in Java. c. Swing components allow the user to specify a uniform look-and-feel across all platforms. d. Swing components allow the user to change the look-and-feel while the program is running.
A - Swing components are less portable but more flexible than the original Java GUI components from package java.awt.
In Java, after an exception is handled, control resumes ___. This is known as the_ model of exception handling.
A - after the last catch block (or the finally block, if there is one), termination
A serialized object is ________. a. an object represented as a sequence of bytes used to store the object's data in a file b. an object in memory that has been recreated from data in a file c. a standard output stream object used to convert objects in code to data in a file d. None of the above.
A - an object represented as a sequence of bytes used to store the object's data in a file
Polymorphism allows for specifics to be dealt with during:
A - execution.
Every object in Java knows its own class and can access this information through method ____ .
A - getClass.
Declaring instance variables ____ is known as data hiding or information hiding.
A - private
Superclass methods with this level of access cannot be called from subclasses.
A - private.
With timeslicing, each thread is given a limited amount of time, called a __, to execute on a processor.
A - quantum
A waiting thread transitions back to the ____ state only when another thread notifies it to continue executing.
A - runnable
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
Which of the following is not an arithmetic operator?Select one: A. + B. . D. - E. %
B - .
___ provides the basic attributes and behaviors of a window—a title bar at the top of the window, and buttons to minimize, maximize and close the window.
B - JFrame.
Modern engineering software development involves a "stack" of software technologies. The "L" in LAMP stands for ___.
B - Linux
Every class in Java, except ____, extends an existing class.
B - Object.
Overriding a method differs from overloading a method because:
B - Overridden methods have the same signature.
__ sockets and the __ protocol which emulate a telephone voice call, are more desirable for the vast majority of Java programmers.
B - Stream, TCP.
Forgetting to register an event-handler object for a particular GUI component's event type causes__.
B - all of the GUI component's events to be ignored.
Two tasks that are operating ____ are both making progress at once.
B - concurrently
Composition is sometimes referred to as a(n) ____ relationship.
B - has-a relationship
Two tasks that are operating ____ are executing simultaneously.
B - in parallel
If the superclass contains only abstract method declarations, the superclass is used for ____.
B - interface inheritance.
Together, the appearance and the way in which the user interacts with the application are known as that application's ____.
B - look-and-feel.
In high performance systems in which _ is abundant, a multithreaded server can quickly assign _ to handle network I/O for new Sockets as connection requests are received.
B - memory, threads
A programmer-defined constructor that has no arguments is called a(n) ____.
B - no-argument constructor.
A JRadioButton is different from a JCheckBox in that ____.
B - normally several JRadioButtons are grouped together and are mutually exclusive.
Method ____ can be used to set the layout manager of a container.
B - setLayout
When an exception occurs it is said to have been ____.
B - thrown.
Java is considered to be a highly portable language because...
C - ... because compiled bytecodes run on a virtual machine which is implemented for each target processor.
Which statement is false? a. The actual data representation used within the class is of no concern to the class's clients. b. Clients generally care about what the class does but not how the class does it. c. Clients are usually involved in a class's implementation. d. Hiding the implementation reduces the possibility that clients will become dependent on class-implementation details.
C - Clients are usually involved in a class's implementation.
Class ____ provides static methods for common file and directory manipulations, including methods for copying files; creating and deleting files and directories; getting information about files and directories; reading the contents of files; getting objects that allow you to manipulate the contents of files and directories; and more.
C - Files
Which of the following statements is false? a. A class can directly inherit from class Object. b. It's often much more efficient to create a class by inheriting from a similar class than to create the class by writing every line of code the new class requires. c. If the class you're inheriting from declares instance variables as private, the inherited class can access those instance variables directly. d. A class's instance variables are normally declared private to enforce good software engineering.
C - If the class you're inheriting from declares instance variables as private, the inherited class can access those instance variables directly.
Which is a correct static method call of Math class method sqrt? a) sqrt(900); b) math.sqrt(900); c) Math.sqrt(900); d) Math math = new Math(); math.sqrt(900);
C - Math.sqrt(900);
Connectionless Datagram service requires __ .
C - No pre-established socket objects.
An advantage of inheritance is that: a. All methods can be inherited. b. All instance variables can be uniformly accessed by subclasses and superclasses. c. Objects of a subclass can be treated like objects of their superclass. d. None of the above.
C - Objects of a subclass can be treated like objects of their superclass.
Which of the following class members should usually be private? a. Methods. b. Constructors. c. Variables (or fields). d. All of the above.
C - Variables (or fields).
Once the ServerSocket is created, the server can listen indefinitely (or block) for an attempt by a client to connect. This is accomplished with a call to the ServerSocket method __.
C - accept
Output __ are typically used to increase the efficiency of an application by sending larger amounts of data fewer times.
C - buffers
Java requires a ____ call for every object that's created.
C - constructor
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.
C - deadlock
An uncaught exception ____.
C - is an exception that occurs for which there are no matching catch clauses.
The _ of a class are also called the public services or the public interface that the class provides to its clients. a. public constructors. b. public instance variables. c. public methods. d. All of the above.
C - public methods
The throws clause of a method: A) specifies the exceptions a method catches. B) specifies the exceptions thrown by the calling method. C) specifies the exceptions a method throws. D) specifies the exceptions a method throws and catches.
C) specifies the exceptions a method throws.
Complete the following analogy. Blueprint is to House as __ is to Object.
Class
Which statement best describes the relationship between superclass and subclass types? a. A subclass reference cannot be assigned to a superclass variable and a superclass reference cannot be assigned to a subclass variable. b. A subclass reference can be assigned to a superclass variable and a superclass reference can be assigned to a subclass variable. c. A superclass reference can be assigned to a subclass variable, but a subclass reference cannot be assigned to a superclass variable. d. A subclass reference can be assigned to a superclass variable, but a superclass reference cannot be assigned to a subclass variable.
D - A subclass reference can be assigned to a superclass variable, but a superclass reference cannot be assigned to a subclass variable.
When must a program explicitly use the this reference?
D - Accessing an instance variable that is shadowed by a local variable.
___ is an I/O-performance-enhancement technique—it reduces the number of I/O operations by combining smaller outputs together in memory; the number of physical I/O operations is much smaller than the number of I/O requests issued by the program.
D - Buffering
For this course, it is REQUIRED that you do not explicitly create and use Thread objects to implement concurrency, but rather use the ____ interface to manage pools of threads.
D - Executor
Which of the following classes is not used for file input? a. FileInputStream b. FileReader c. ObjectInputStream d. Formatter
D - Formatter
A(n) __ is thrown when a server address indicated by a client cannot be resolved.
D - UnknownHostException
A JLabel can be attached to a JFrame using method ____.
D - add
Which of the following answers does not complete the sentence correctly?An anonymous inner class __ . a. is frequently used for GUI event handling. b. is non-static. c. does not need a handle to its outer class to access its methods and variables. d. cannot be declared private.
D - cannot be declared private.
Non-abstract classes are called ________. a. real classes. b. instance classes. c. implementable classes. d. concrete classes.
D - concrete classes.
Which of the following is not a control structure: -_-
D - declaration
A programmer must do the following before using an array: a.Declare then reference the array. b.Create then declare the array. c.Create then reference the array. d.Declare then create the array.
D - declare then create the array.
Inheritance is also known as the _ relationship.
D - is-a relationship.
Declaring a method final means:
D - it cannot be overridden.
When a superclass variable refers to a subclass object and a method is called on that object, the proper implementation is determined at execution time. What is the process of determining the correct method to call?
D - late binding.
A new thread begins its life cycle by transitioning to the __ state.
D - new.
Java's predefined classes are grouped into
D - packages
For this course, the correct means of creating multi-threaded Java applications is by implementing the ________ interface. An object of a class that implements this interface represents a task to perform Thread Runner Runnable None of the above
Runnable
{Placeholder for missing Static access modifier question}
Too bad the questions were not posted.
{Placeholder for missing UML question}
Too bad the questions were not posted.
{Placeholder for missing finally question}
Too bad the questions were not posted.
{Placeholder for missing thread question}
Too bad the questions were not posted.
Which SQL keyword is required in every query? a) FROM. b) WHERE. c) ORDER BY. d) LIKE.
a) FROM.
This keyword is used to add a row to a table. a) INSERT. b) ADD. c) UPDATE. d) CREATE.
a) INSERT.
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.
Which of the following is stateless? a. JButton. b. JToggleButton. c. JRadioButton. d. JCheckBox.
a. JButton.
Which of the following statements is true? a. Methods and instance variables can both be either public or private. b. Information hiding is achieved by restricting access to class members via keyword public. c. The private members of a class are directly accessible to the client of a class. d. None of the above is true.
a. Methods and instance variables can both be either public or private.
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.
Polymorphism enables you to: a. program in the general. b. program in the specific. c. absorb attributes and behavior from previous classes. d. hide information from the user.
a. program in the general.
The length of a string can be determined by ________. a. the String method length() b. the String instance variable length c. the String method strlen() d. All of the above.
a. the String method length()
Which statement is false? a.With datagram sockets a process establishes a connection to another process. b.The TCP protocol is used for transmission with stream sockets. c.The UDP protocol is used for transmission with datagram sockets. d.With the UDP protocol packets can be lost, duplicated, or even arrive out of sequence.
a.With datagram sockets a process establishes a connection to another process.
A(n) __________ class cannot be instantiated.
abstract
Which of the following is a key benefit of using JDBC? a) It is a simple-to-use database management system. b) Allows developers to change the underlying database without modifying the Java code. c) It is a multi-platform database management system. d) It provides a GUI for database management systems.
b) Allows developers to change the underlying database without modifying the Java code.
To obtain data from a table, you ________ the database? a) select. b) query. c) get. d) None of the above.
b) query.
private fields of a superclass can be accessed in a subclass a. by calling private methods declared in the superclass. b. by calling public or protected methods declared in the superclass. c. directly. d. All of the above.
b. by calling public or protected methods declared in the superclass.
Using the protected keyword also gives a member: a. public access. b. package access. c. private access. d. block scope.
b. package access.
Which of the following statements makes the text in a JTextField uneditable? a. textField.setEditable( true ); b. textField.setEditable( false ); c. textField.setUneditable( true ); d. textField.setUneditable( false );
b. textField.setEditable( false );
Which statement is false? a.Streams-based transmission is connection-oriented. b.Connection-oriented transmission is like the telephone system. c.Datagram-based transmission is connection oriented. d.Connectionless transmission is like the way the mail is carried by the postal service.
c. Datagram-based transmission is connection oriented.
Which of the following statements is true? a. The capacity of a StringBuilder is equal to its length. b. The capacity of a StringBuilder cannot exceed its length. c. The length of a StringBuilder cannot exceed its capacity. d. Both a and b are true.
c. The length of a StringBuilder cannot exceed its capacity.
Which of the following statements about anonymous inner classes is false? a. They are declared without a name. b. They typically appear inside a method declaration. c. They are declared with the anonymous keyword. d. They can access their top-level class's members.
c. They are declared with the anonymous keyword.
Which of the following does not generate GUI events? a. Typing in a text field. b. Selecting an item from a menu. c. Viewing the text in a label. d. Moving the mouse.
c. Viewing the text in a label.
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
A constructor cannot: a. be overloaded. b. initialize variables to their defaults. c. specify return types or return values. d. have the same name as the class.
c. specify return types or return values.
The Internet address 128.0.0.1 is also known as __. (Probably a typo? 127.0.0.1 instead?) a) remoteserver b) remotehost c) localserver d) localhost
d) localhost
14.3.2 Q2: 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.
Which of the following most completely describes the steps for setting up event handling for a GUI component? a. Create a class that represents the event handler, attach the JFrame to a JWindow object and register the event handler. b. Implement an appropriate event-listener interface and register the event handler. c. Create a class that represents the event handler and implement an appropriate event-listener interface. d. Create a class that represents the event handler, implement an appropriate event-listener interface and register the event handler.
d. Create a class that represents the event handler, implement an appropriate event-listener interface and register the event handler.
Which of the following statements is false? a. Storage of data variables and arrays is temporary. b. Data is lost when a local variable "goes out of scope." c. Files are used for long-term retention of large amounts of data. d. Data maintained in files is often called transient data.
d. Data maintained in files is often called transient data
Which of the following statements for a JTextField is false? a. Can be used to display uneditable text. b. Can be used to display editable text. c. Enables users to enter data from the keyboard. d. Displays a list of fields.
d. Displays a list of fields.
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.
Which of the following is the method used to display a dialog box to gather input? a. showMessageDialog. b. getInput. c. inputDialog. d. showInputDialog.
d. showInputDialog.
Which of the following keywords allows a subclass to access a superclass method even when the subclass has overridden the superclass method? a. base. b. this. c. public. d. super.
d. super.
Arrays are __
fixed-length entities
Overloaded methods always have the same _________.
method name