Section 1

Preview this deck

Which statement correctly passes the array items to method takeArray? Array items contains 10 elements.

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 14, 2020

Cards (88)

Section 1

(50 cards)

Which statement correctly passes the array items to method takeArray? Array items contains 10 elements.

Front

takeArray( items )

Back

Using the protected keyword gives a member:

Front

package access

Back

Overriding a method differs from overloading a method because:

Front

Overridden methods have the same signature.

Back

The default implementation of method clone of Object performs a ________.

Front

shallow copy

Back

Which of the following statements is false?

Front

Information in the memory unit is persistent—it is retained when the computer's power is turned off

Back

Which class provides prebuilt dialog boxes that enable programs to display windows containing messages (such windows are called message dialogs)?

Front

JOptionPane

Back

Static class variables:

Front

are shared by all objects of a class.

Back

The Java API consists of import declarations.

Front

false

Back

Declaring main as ________ allows the JVM to invoke main without creating an instance of the class.

Front

static.

Back

Objects are marked for garbage collection by method finalize.

Front

false

Back

Which of the following should usually be private?

Front

Variables (or fields).

Back

Attributes of a class are also known as:

Front

fields

Back

Which of the following is not a control structure:

Front

Declaration Structure

Back

What do the following statements do? double[] array; array = new double[ 14 ]; Answer

Front

Create a double array containing 14 elements.

Back

In this question, assume a class, Book, has been defined. Which set of statements creates an array of Book objects?

Front

Book[] books; books = new Book[ numberElements ];

Back

Stacks are known as ________ data structures.

Front

LIFO

Back

________ models software in terms similar to those that people use to describe real-world objects.

Front

Object-oriented design

Back

When should a program explicitly use the this reference?

Front

Accessing a field that is shadowed by a local variable.

Back

Instance variables declared final do not or cannot:

Front

Be modified.

Back

A well-designed method

Front

performs a single, well-defined task.

Back

In a class containing methods with the same name, the methods are distinguished by:

Front

(a) and (b).

Back

Suppose method1 is declared as void method1 ( int a, float b ) Which of the following methods correctly overloads method1?

Front

void method1 ( float a, int b ).

Back

What does the expression x %= 10 do?

Front

Divides x by 10 and stores the remainder in x.

Back

Every class in Java, except ________, extends an existing class.

Front

Object

Back

Which command executes the Java class file Welcome.class?

Front

java Welcome

Back

int x = 9; double y = 5.3; result = calculateValue( x, y ); Which of the following statements is false?

Front

x and y are parameters.

Back

Which statement creates a random value from the sequence 2, 5, 8, 11 and 14. Suppose randomNumbers is a Random object.

Front

2 + 3 * randomNumbers.nextInt( 5 );

Back

Which of the following statements about a do...while repetition statement is true?

Front

The body of a do...while loop is always executed at least once.

Back

An overloaded method is one that

Front

has the same name as another method, but different parameters (by number, types or order of the types).

Back

A class within a package must be declared public if

Front

It will be used by classes that are not in the same package.

Back

A(n) ________ enables a program to read data from the user.

Front

Scanner

Back

Which statement best describes the relationship between superclass and subclass types?

Front

A subclass reference can be assigned to a superclass variable, but a superclass reference cannot be assigned to a subclass variable.

Back

What is the difference between a float and a double?

Front

Double variables store numbers with larger magnitude and finer detail.

Back

Every Java application is composed of at least one:

Front

public class declaration

Back

Superclass methods with this level of access cannot be called from subclasses.

Front

private

Back

Failure to prefix the superclass method name with the keyword super and a dot (.) separator when referencing the superclass's method causes ________.

Front

infinite recursion

Back

Arrays are:

Front

fixed-length entities.

Back

Which of the following is not a Java primitive type?

Front

real

Back

Which of the following statements about the break statement is false?

Front

The break statement, when executed in a while, for or do...while, skips the remaining statements in the loop body and proceeds with the next iteration of the loop.

Back

When a subclass constructor calls its superclass constructor, what happens if the superclass's constructor does not assign a value to an instance variable?

Front

The program compiles and runs because the instance variables are initialized to their default values

Back

An advantage of inheritance is that:

Front

Objects of a subclass can be treated like objects of their superclass.

Back

is a graphical language that allows people who design software systems to use an industry stan¬dard notation to represent them.

Front

The Unified Modeling Language

Back

Which method call converts the value in variable stringVariable to an integer?

Front

Integer.parseInt( stringVariable ).

Back

The import declaration import *; ________.

Front

causes a compilation error.

Back

When no access modifier is specified for a method or variable, the method or variable:

Front

Has package access.

Back

To declare a method as static, place the keyword static before ________ in the method's declaration.

Front

static

Back

To exit out of a loop completely, and resume the flow of control at the next line in the method, use _______.

Front

A break statement.

Back

Attempting to access an array element out of the bounds of an array, causes a(n)

Front

ArrayIndexOutOfBoundsException.

Back

What is the result value of c at the end of the following code segment? int c = 8; c++; ++c; c %= 5; Answer

Front

0

Back

A programmer must do the following before using an array:

Front

declare then create the array.

Back

Section 2

(38 cards)

Polymorphism allows for specifics to be dealt with during:

Front

execution

Back

The classes and interfaces which comprise the collections framework are members of package ________.

Front

java.util

Back

A non-generic class cannot be derived from a generic class

Front

false

Back

Using a URL as an argument to the __________ method of interface AppletContext causes the browser in which an applet is executing to display the URL

Front

showDocument

Back

All exception classes inherit, either directly or indirectly, from:

Front

class Throwable

Back

With datagram sockets a process establishes a connection to another process

Front

false

Back

Which keyword is used to specify that a class will define the methods of an interface?

Front

implements

Back

__________ enable programmers to specify, with a single method declaration, a set of related methods.

Front

Generic methods

Back

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.

Front

synchronized

Back

The collections framework algorithms are __________, i.e., each of these algorithms can operate on objects that offer given interfaces without concern to the underlying implementations.

Front

polymorphic

Back

When the compiler translates a generic method into Java bytecodes, it uses __________ to replace the type parameters with actual types.

Front

erasure

Back

A(n) _________ is thrown when a String that is not in proper URL format is passed to a URL constructor

Front

MalformedURLException

Back

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 __________

Front

accept

Back

Polymorphism enables you to:

Front

program in the general

Back

Which of the following statements about try blocks is true?

Front

The try block should contain statements that may throw an exception

Back

A new thread begins its life cycle by transitioning to the __________ state.

Front

new

Back

Non-abstract classes are called:

Front

concrete classes

Back

Which of the following is not true of ExecutorService?

Front

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

Back

The main method executes in the ________ thread of execution.

Front

main

Back

If an ObjectInputStream is used to read information from the server, an __________ is generated when the client attempts to read a value from a stream on which end-of-stream is detected

Front

EOFException

Back

A(n) __________ allows a program to walk through the collection and remove elements from the collection.

Front

Iterator

Back

When a generic class is instantiated without specifying a type argument, it is said to have a __________.

Front

raw type

Back

An uncaught exception:

Front

is an exception that occurs for which there are no matching catch clauses.

Back

To catch an exception, the code that might throw the exception must be enclosed in a

Front

try block

Back

In the catch block below, what is arithmeticException? catch ( ArithmeticException arithmeticException ) { System.err.printf( arithmeticException ); } // end catch

Front

The name of catch block's exception parameter

Back

__________ sockets and the __________ protocol are more desirable for the vast majority of Java programmers.

Front

Stream, TCP

Back

Declaring a method final means:

Front

it cannot be overridden

Back

Collections method sort that accepts a List as an argument sorts the elements of a List, which must implement the __________ interface.

Front

Comparable

Back

One generic Stack class could be the basis for creating many Stack classes, e.g., Stack<Double>, Stack<Integer> and Stack<Employee>. These classes are known as __________.

Front

parameterized classes

Back

Which of the following statements about abstract superclasses is true?

Front

abstract superclasses may contain data

Back

All of the following methods are implicitly final except:

Front

a method in an abstract class

Back

A(n) __________ is thrown when a server address indicated by a client cannot be resolved

Front

UnknownHostException

Back

Which statement is false? Normally, an applet __________

Front

can read files on any server that can be reached over the network

Back

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.

Front

Runnable

Back

A(n) __________ class cannot be instantiated.

Front

abstract

Back

A JEditorPane generates HyperlinkEvents only if it is __________

Front

uneditable

Back

Which statement is false?

Front

A List cannot contain duplicate elements

Back

UDP is a connection-oriented protocol

Front

false

Back