Section 1

Preview this deck

T/F: The parameter type in the following method is double. public static double getAmount(int ID) {...}

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 1, 2020

Cards (73)

Section 1

(50 cards)

T/F: The parameter type in the following method is double. public static double getAmount(int ID) {...}

Front

False

Back

True/False: You use the File class to obtain information about a file, such as whether it exists or is open, its size, and its last modification date.

Front

True

Back

What is the output of the following code segment? int a = 45; do { System.out.println("a++ = " + a++); } while (a > 100);

Front

a++=45

Back

Which one of the following modifiers has the lowest level of security?

Front

public

Back

A method body is included within _____.

Front

curly braces

Back

What is the output of the following code segment? int n = 5; int i; for (i=0; i < 10; i++); n += i; System.out.println("n = " + n);

Front

n=15

Back

T/F: A programmer can declare methods outside a Java class.

Front

False

Back

An example of a primitive data type is _____.

Front

char

Back

T/F: The body of a while loop is executed at least once.

Front

false

Back

True/False: When you create a segment of code in which something might go wrong, you place the code in a try block.

Front

True

Back

The result of the following expression is _____. 6 + 2 * 3 - 4

Front

8

Back

To exit a program successfully, you use _____.

Front

System.exit(0);

Back

True/False: Computer users use the term file to describe the objects that they store on permanent storage devices.

Front

True

Back

True/False: When a Thread is in the ready state, isAlive() returns true.

Front

False

Back

Any ArithmeticException generated within the try block in the program would be caught by the _______.

Front

catch block

Back

The read() method in the following statement reads a(n) _____. System.in.read();

Front

byte

Back

What is the value of x after the following statements are executed? int x = 0; int y = 10; x = ++y;

Front

11

Back

True/False: Multithreaded programs often run slower.

Front

True

Back

Which of the following is not an element of the try block?

Front

a catch

Back

To create standard dialog boxes, you use _____.

Front

JOptionPane

Back

True/False: When you run a Java program, the runnable Thread with the lowest priority runs first.

Front

False

Back

True/False: In Java, there is one basic class of errors: Exception.

Front

False

Back

When a Thread completes the execution of its run() method, its state is _____.

Front

Inactive

Back

You can use the ----------( ) method that ArithmeticException inherits from the Throwable class. To retrieve Java's message about any Throwable Exception named someException, you code someException.getMessage().

Front

getMessage

Back

True/False: An exception is an unexpected or error condition.

Front

True

Back

Which of the following comprises less serious errors that represent unusual conditions that arise while a program is running, and from which the program can recover?

Front

Exception Class

Back

True/False: When you have actions you must perform at the end of a try... catch sequence, you can use a catch block.

Front

False

Back

When you have actions you must perform at the end of a try...catch sequence, you can use a ------ block. The code within a ------ block executes whether or not the preceding try block identifies Exceptions. Usually, you use a ------ block to perform clean-up tasks that must happen whether or not any Exceptions occurred, and whether or not any Exceptions that occurred were caught.

Front

finally

Back

T/F: Encapsulation means putting data and related methods in a self-contained class.

Front

True

Back

What is the value of x after the following statements are executed? int x = 0; int y = 10; x = y++;

Front

10

Back

When you create a thread, which state would it be in?

Front

New

Back

True/False: If you do not assign a priority to a Thread object it assumes a default priority of 5.

Front

True

Back

True/False: You can place as many place as many statements as you need within a try block; only the last error-generating statement throws an exception.

Front

False

Back

The Error class represents errors which your program usually _____.

Front

cannot recover from

Back

T/F: To store a value explicitly as a float, you can type the letter F after the number.

Front

True

Back

The File class is a direct descendant of the _____.

Front

Object class

Back

True/False: InputStream and OutputStream are abstract classes that contain methods for performing input and output.

Front

True

Back

When you write a method that might throw an Exception, you can type the clause ------ after the method header to indicate the type of Exception that might be thrown.

Front

throws <name>Exception

Back

The input dialog box returns a(n) _____.

Front

String

Back

A ----- block is a segment of code that can handle an Exception that might be thrown by the try block that precedes it. Each ----- block can "-----" one type of Exception. A ----- block looks a lot like a -----( ) method that takes an argument that is some type of Exception. However, it is not a method; it has no return type, and you can't call it directly.

Front

catch

Back

An exception is an ----- that occurs during the execution of a program that ----- the normal flow of instructions.

Front

event, disrupts

Back

Each catch block can "catch" how many types of Exceptions?

Front

one type

Back

T/F: The following loop has a(n) infinite body.while(loopCount > 20);

Front

false

Back

T/F: A method can also return nothing, in which case the return type is null.

Front

False

Back

The value of compare1 after the following statements are executed is _____. int x = 249; int y = 250; boolean compare1 = (x++ = = y);

Front

false

Back

True/False: You must include the statement java.import in any program that uses the file class.

Front

False

Back

If a method throws an Exception that will be caught, you must also use the keyword throws, followed by a(n) _____ in the method header.

Front

Exception Type

Back

The situation when two Threads are waiting for each other to do something before either can progress is called _____.

Front

deadlock

Back

If you are writing applet classes and you need to use threads, you would _____.

Front

implement the runnable interface

Back

Where is the Thread class defined?

Front

java.lang

Back

Section 2

(23 cards)

What is the value of x after the following statements are executed? int x = 0; int y = 10; x = y++;

Front

10

Back

In a class called Boat, the constructor name is _____.

Front

Back

The value of x after the following statements execute is _____. int x = 15; int y = 10; x += y;

Front

25

Back

What is the output of the following program?public class Test { public static void main(String [] args ) { method1(1234567, 85742157.15); } public static void method1(int x, double y) { System.out.println("method1(int x, double y)"); } public static void method1(long x, double y) { System.out.println("method1(long x, double y)"); } public static void method1(int x, float y) { System.out.println("method1(int x, float y)"); }}

Front

Back

Assume you have a Circle class with a nonstatic data member named radius. If you create two objects of the Circle class, how many copies of radius will you have?

Front

Back

Polymorphism manifests itself in _____ in Java.

Front

Back

T/F: A constructor cannot be overloaded.

Front

Back

Declaring data as private in a class is an example of _____.

Front

Back

T/F: Constructor methods can have return types.

Front

Back

How many objects of a given class can there be in a program?

Front

Back

What is the value of x after the following statements are executed? int x = 0; int y = 10; x = ++y;

Front

11

Back

T/F: The allowable field modifiers are private, public, static, and external.

Front

Back

T/F: 'abstract' is an example of an access modifier.

Front

Back

Does a subclass inherit both member variables and methods?

Front

Back

Choose the statement that is similar to the following. if (X > Y) Z = X; else Z = Y;

Front

Z = (X > Y) ? X : Y;

Back

You have an Account class with a static member named numAccounts. If you create 4 objects of the Account class, how many copies of numAccounts do you have?

Front

Back

What is an abstract class?

Front

Back

T/F: All methods in abstract superclass must be declared abstract.

Front

Back

T/F: You can use the keyword constant for data fields that do not change throughout the execution of the program.

Front

Back

T/F: The constructor method assigns values to data fields at the time of the object creation.

Front

Back

T/F: Static methods are methods that belong to a class.

Front

Back

If you have a variable named salary in the Employee class, you would most likely _____.

Front

Back

What is the output of the following code segment? int x = 0; int i, j; for (i = 0; i < 10; i++) for (j = 10; j > 4; j--) x += 1; System.out.println("x = " + x);

Front

x=60

Back