Section 1

Preview this deck

A constructor ____ parameters. a. must receive b. cannot receive c. can receive a maximum of 10 d. can receive

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

4 years ago

Date created

Mar 1, 2020

Cards (140)

Section 1

(50 cards)

A constructor ____ parameters. a. must receive b. cannot receive c. can receive a maximum of 10 d. can receive

Front

can receive

Back

If a method is written to receive a double parameter, and you pass an integer to the method, then the method will ____.

Front

work correctly; the integer will be promoted to a double

Back

To create interactive programs that accept input from a user, you can use ____.

Front

System.in

Back

Java classes are stored in a folder or ____.

Front

package

Back

____ describes the relationship between classes when an object of one class is a data field within another class.

Front

Composition

Back

The code between a pair of curly braces in a method is a ____.

Front

block

Back

A constructor ____ overloaded. a. must be b. cannot be c. can be d. is always automaticall

Front

can be

Back

If you attempt to add a float, an int, and a byte, the result will be a(n) ____.

Front

float

Back

Which of the following data types can store a value in the least amount of memory?

Front

byte

Back

The method public static boolean testValue(int response) returns ____.

Front

a boolean value

Back

Identify the false statement. a. Methods declared as static receive a this reference that contains a reference to the object associated with them. b. A final static field's value is shared by every object of a class. c. Methods declared as static are called class methods.

Front

Methods declared as static receive a this reference that contains a reference to the object associated with them.

Back

Java is architecturally ____.

Front

neutral

Back

Java does not execute instructions on a computer directly, but rather on the ____.

Front

Java Virtual Machine

Back

Which of the following could be the last legally coded line of a method declared as public static int getVal(double sum)? a. return 2.3; b. Any of these could be the last coded line of the method. c. return; d. return 77;

Front

return 77;

Back

Identify the false statement. a. A variable declaration is a statement that reserves a named memory location and includes a data type, an identifier, an optional assignment operator and assigned value, and an ending semicolon. b. An item's data type determines what legal identifiers can be used to describe variables and whether the variables can occupy memory. c. A variable is a named memory location that you can use to store a value; it can hold only one value at a time, but the value it holds can change.

Front

An item's data type determines what legal identifiers can be used to describe variables and whether the variables can occupy memory.

Back

Identify the false statement. a. A variable of type int can hold any whole number value from approximately negative two billion to positive two billion. b. You can use the data types byte or short to hold larger values than can be accommodated by an int. c. When you assign a value to an int variable, you do not type any commas; you type only digits and an optional plus or minus sign to indicate a positive or negative integer.

Front

You can use the data types byte or short to hold larger values than can be accommodated by an int.

Back

Identify the false statement. a. A method header always contains a return type, an identifier, and a parameter list within parentheses. b. Arguments are used in method calls; they are passed to parameters in method headers. c. A class can contain any number of methods, and each method can be called any number of times.

Front

A method header always contains a return type, an identifier, and a parameter list within parentheses.

Back

When you run your program you don't see evidence of the changes you just made to it. You realize that you forgot to ____ the program.

Front

recompile

Back

Identify the false statement. a. When you declare a primitive variable or instantiate an object from a class, you provide both a type and an identifier. b. Unlike a primitive variable, an instantiated object cannot be passed into or returned from a method. c. The address of an instantiated object can be assigned to a declared reference of the same type.

Front

Unlike a primitive variable, an instantiated object cannot be passed into or returned from a method.

Back

Identify the false statement. a. In the method header public static void main(String[] args), the word static means that a method is accessible and usable, even though no objects of the class exist. b. In the method header public static void main(String[] args), the word void means that the main() method is an empty method. c. In the method header public static void main(String[] args), the word public is an access specifier.

Front

In the method header public static void main(String[] args), the word void means that the main() method is an empty method.

Back

Identify the false statement. a. A nested class resides within another class. b. Exposition describes the relationship between classes when an object of one class is a data field within another class. c. When you use an object as a data member of another object, you must remember to supply values for the contained object if it has no default constructor.

Front

Exposition describes the relationship between classes when an object of one class is a data field within another class.

Back

Identify the false statement. a. Assume that myName is a String defined as "molly". The value of myName.indexOf('M') is -1. b. Assume that myName is a String defined as "molly". The value of myName.toUpperCase() is "Molly". c. Assume that myName is a String defined as "molly". The value of myName.length() is "5".

Front

Assume that myName is a String defined as "molly". The value of myName.toUpperCase() is "Molly".

Back

Identify the false statement. a. When a method is declared with public access, methods in other classes can call it. b. Not all methods return a value, but every method requires a return type. c. A method header is also called an implementation.

Front

A method header is also called an implementation.

Back

Non-executing program statements that provide documentation are called program ____.

Front

comments

Back

Which of the following elements is not required in a variable declaration?

Front

an assigned value

Back

If you create a class that contains one method and then instantiate two objects, you usually store ____ for use with the objects.

Front

one copy of the method

Back

Identify the false statement. a. When it is part of the same program as void myMethod (int age, String name), the following method would be ambiguous: String myMethod (int zipCode, String address) b. When it is part of the same program as void myMethod (int age, String name), the following method would be ambiguous: void myMethod (int x, String y) c. When it is part of the same program as void myMethod (int age, String name), the following method would be ambiguous: void myMethod (String name, int age)

Front

When it is part of the same program as void myMethod (int age, String name), the following method would be ambiguous: void myMethod (String name, int age)

Back

The most basic circuitry-level computer language, which consists of on and off switches, is ____.

Front

machine language

Back

If you use the automatically-supplied default constructor when you create an object, ____.

Front

numeric fields are set to 0 (zero)

Back

The individual operations used in a computer program are often grouped into logical units called ____.

Front

procedures

Back

The principle used in creating private access is sometimes called ____ and is an important component of object-oriented programs.

Front

information hiding

Back

Most class data fields are ____.

Front

private

Back

Unlike when you create a String, when you create a StringBuilder, you must use the keyword _____.

Front

new

Back

Identify the false statement. a. When you create a String, you have the option of omitting the keyword new, but when you initialize a StringBuilder object, you must use the keyword new, the constructor name, and an initializing value between the constructor's parentheses. b. When you create a StringBuilder object with an initial value of "Juan", its capacity is 16. c. If a StringBuilder named myAddress contains "817", then myAddress.append(" Maple Lane"); alters myAddress to contain "817 Maple Lane".

Front

When you create a StringBuilder object with an initial value of "Juan", its capacity is 16.

Back

If a class is named Student, the class constructor name is____.

Front

Student()

Back

A sequence of characters enclosed within double quotation marks is a _____.

Front

literal string

Back

The compiler determines which version of a method to call by the method's ____.

Front

signature

Back

The method with the declaration public static int aMethod() has a method type of ____.

Front

int

Back

The toString() method converts a(n) _____ to a String. a. char b. float c. int d. all of the above

Front

all of the above

Back

The method that extracts a string from within another string is _____.

Front

substring()

Back

Which of the following is not an option that can be displayed with a confirm dialog box? a. Yes b. Try Again c. Cancel d. No

Front

Try Again

Back

Using a method name to contain or encapsulate a series of statements is an example of ____.

Front

abstraction

Back

Identify the false statement. a. Javadoc comments begin with a forward slash and two asterisks ( /* ) and end with an asterisk and a forward slash ( / ); they are used to generate documentation with a program named javadoc. b. Line comments start with two forward slashes ( // ) and end with two backslashes ( \\ ); they can extend across as many lines as needed. c. Block comments start with a forward slash and an asterisk ( / ) and end with an asterisk and a forward slash ( / ); they can extend across as many lines as needed.

Front

Line comments start with two forward slashes ( // ) and end with two backslashes ( \\ ); they can extend across as many lines as needed.

Back

Identify the false statement. a. An object name is a reference; it holds a memory address. b. When you declare an object, you give it a name and set aside enough memory for the object to be stored. c. When you don't write a constructor for a class, Java creates one for you; the name of the constructor is always the same as the name of its class.

Front

When you declare an object, you give it a name and set aside enough memory for the object to be stored.

Back

Identify the false statement. a. When you compare Strings with the == operator, you are comparing their memory addresses, not their values. b. To create a String object, you must use the keyword new and explicitly call the class constructor. c. When you compare Strings with the equals() method, you are comparing their values, not their memory addresses.

Front

To create a String object, you must use the keyword new and explicitly call the class constructor.

Back

Identify the false statement. a. Java packages are available only if you explicitly name them within your program. b. The creators of Java have produced hundreds of classes for you to use in your programs. c. The implicitly imported java.lang package contains fundamental Java classes.

Front

Java packages are available only if you explicitly name them within your program.

Back

Identify the false statement. a. A class's instance variables override locally declared variables with the same names that are declared within the class's methods. b. You cannot declare the same variable name more than once within a block, even if a block contains other blocks. c. A variable ceases to exist, or goes out of scope, at the end of the block in which it is declared.

Front

A class's instance variables override locally declared variables with the same names that are declared within the class's methods.

Back

The remainder operator ____.

Front

is also called the modulus operator

Back

A ____ translates high-level language statements into machine code.

Front

compiler

Back

The first position in a String _____.

Front

is position zero

Back

Section 2

(50 cards)

Identify the false statement. a. An escape sequence always begins with a backslash followed by a character; the pair represents a single character. b. To store a string of characters, you use a data structure called a Text; string constants are written between parentheses. c. You use the char data type to hold any single character; you place constant character values within single quotation marks.

Front

To store a string of characters, you use a data structure called a Text; string constants are written between parentheses.

Back

A(n) ____ is a program module that contains a series of statements that carry out a task.

Front

method

Back

A String variable name is a _____ which is a variable that holds a memory address.

Front

reference

Back

Identify the false statement. a. To compile a file named MyProgram.java, you type java MyProgram, but to execute the program you type java MyProgram.java. b. When you compile a program, sometimes one error in syntax causes multiple error messages. c. In Java, if a class is public, you must save the class in a file with exactly the same name and a .java extension.

Front

To compile a file named MyProgram.java, you type java MyProgram, but to execute the program you type java MyProgram.java.

Back

If a class's only constructor requires an argument, you ____ for every object of the class that you create.

Front

must provide an argument

Back

Identify the false statement. a. You can create an input dialog box using the showInputDialog() method; the method returns a String that represents a user's response. b. You can use methods from the Java classes Integer and Double when you want to convert a dialog box's returned values to numbers. c. A confirm dialog box can be created using the showConfirmDialog() method in the JOptionPane class; a confirm dialog box displays the options Accept, Reject, and Escape.

Front

A confirm dialog box can be created using the showConfirmDialog() method in the JOptionPane class; a confirm dialog box displays the options Accept, Reject, and Escape.

Back

Using a(n) ____ statement, Java allows you to access built-in classes that are contained in a group of classes called a package.

Front

import

Back

The method parseInt() converts a(n) _____.

Front

String to an integer

Back

A(n) ____ statement causes a method to end and the program's logic to return to the calling method.

Front

return

Back

Identify the false statement. a. Character, String, and StringBuilder are useful built-in classes for working with text data. b. A String is a simple data type that can hold text data. c. Programmers want to compare the values of Strings more frequently than they want to compare their memory addresses.

Front

A String is a simple data type that can hold text data.

Back

After you write and save a Java application file, you ____ and then ____ it.

Front

compile, interpret

Back

Identify the false statement. a. A class header contains an optional access specifier, the keyword class, and an Identifier. b. When you instantiate objects, each has its own copy of each static data field in the class. c. Most fields in a class are private, and most methods are public.

Front

When you instantiate objects, each has its own copy of each static data field in the class.

Back

Identify the false statement. a. As with integers, you can perform the mathematical operations of addition, subtraction, multiplication, and division with floating-point numbers. b. Java supports two floating-point data types: float and double. The double data type requires more memory and can hold more significant digits. c. A floating-point constant, such as 5.6, is a float by default.

Front

A floating-point constant, such as 5.6, is a float by default.

Back

Identify the false statement. a. System.in refers to the standard input device, which normally is the keyboard. b. When a user types data followed by the Enter key, the Enter key character is left in the keyboard buffer after Scanner class methods retrieve the other keystrokes. c. System.in is more flexible than System.out because it can read all the basic Java data types.

Front

System.in is more flexible than System.out because it can read all the basic Java data types.

Back

Named computer memory locations are called ____.

Front

variables

Back

Methods that do not have a this reference because they have no object associated with them are called ____ methods.

Front

class

Back

Arguments to methods always appear within ____.

Front

parentheses

Back

Variables that are shared by every instantiation of a class are ____.

Front

class variables

Back

Envisioning program components as objects that are similar to concrete objects in the real world is the hallmark of ____.

Front

object-oriented programming

Back

The values of an object's attributes also are known as its ____.

Front

state

Back

You save text files containing Java source code using the file extension ____.

Front

.java

Back

A method is declared as public static void showResults(double d, int i). Which of the following is a correct method call? a. Two of these are correct b. showResults(4, 99.7); c. showResults(12.2, 67); d. showResults(double d, int i);

Front

showResults(12.2, 67);

Back

All Java programming statements must end with a ____.

Front

semicolon

Back

The difference between int and Integer is _____.

Front

int is a primitive type; Integer is a class

Back

A program or class that instantiates objects of another prewritten class is a(n) ____.

Front

class client

Back

Identify the false statement. a. An application or class that instantiates objects of another prewritten class is a class client. b. A class is an instantiation of many objects. c. Objects gain their attributes and methods from their classes.

Front

A class is an instantiation of many objects.

Back

A(n) ____ data type is a type whose implementation is hidden and accessed through its public methods.

Front

abstract

Back

The "equal to" relational operator is ____.

Front

==

Back

Identify the false statement. a. The return type for a method can be any type used in Java, including int, double, and void. b. You cannot place a method within another method, but you can call a method from within another method. c. A method's declared return type must match the type of the value used in the parameter list.

Front

A method's declared return type must match the type of the value used in the parameter list.

Back

In Java, ____ means writing multiple methods in the same scope that have the same name but different parameter lists.

Front

overloading

Back

If you declare a variable as an instance variable within a class and you declare and use the same variable name within a method of the class, then within the method ____.

Front

the variable used inside the method takes precedence

Back

Identify the false statement. a. Static methods are instance methods. b. The keyword static is used with classwide methods, but not for methods that "belong" to objects. c. When you create a class from which objects will be instantiated, most methods are nonstatic because they are associated with individual objects.

Front

Static methods are instance methods.

Back

All method declarations contain ____.

Front

parentheses

Back

Which of the following is a correct call to a method declared as public static void aMethod(char code)? a. void aMethod(); b. aMethod('Q'); c. void aMethod('V'); d. aMethod(char 'M');

Front

aMethod('Q');

Back

Which of the following is not a primitive data type in Java? a. byte b. int c. boolean d. sector

Front

sector

Back

A(n) ____ is a data type that consists of a list of values.

Front

enumeration

Back

An instance of a class is a(n) ____.

Front

object

Back

A boolean variable can hold ____.

Front

the value true or false

Back

Assuming you have declared balance to be a variable of type int, which of the following is a valid assignment statement in Java? a. balance = 9,000; b. balance = 9000; c. balance = 9000.5; d. balance = '9000';

Front

balance = 9000;

Back

The reference to an object that is passed to any object's nonstatic method is called the ____.

Front

this reference

Back

The rules of a programming language constitute its ____.

Front

syntax

Back

Which of the following statements determines the square root of a number and assigns it to the variable s? a. s = Math.sqrt(number); b. s = sqrt(number); c. number = Math.sqrt(s); d. number = sqrt(s);

Front

s = Math.sqrt(number);

Back

Identify the false statement. a. A default constructor is one that is automatically created. b. When you write a constructor, it can be written to receive parameters or not. c. If a class's only constructor requires an argument, you must provide an argument for every object of the class that you create.

Front

A default constructor is one that is automatically created.

Back

Identify the false statement. a. In Java, operator precedence dictates that multiplication, division, and remainder always take place prior to addition or subtraction in an expression. b. The arithmetic operators are examples of unary operators, which are so named because they perform one operation at a time. c. Floating-point arithmetic might produce imprecise results.

Front

The arithmetic operators are examples of unary operators, which are so named because they perform one operation at a time.

Back

Identify the false statement. a. Polymorphism is the ability to create classes that share the attributes and methods of existing classes, but with more specific features. b. An instance of a class is a created object that possesses the attributes and methods described in the class definition. c. Encapsulation protects data by hiding it within an object.

Front

Polymorphism is the ability to create classes that share the attributes and methods of existing classes, but with more specific features.

Back

Identify the false statement. a. Any class can contain an unlimited number of methods. b. A method is usually written within another method. c. During one program execution, a method might be called any number of times.

Front

A method is usually written within another method.

Back

When a block exists within another block, the blocks are ____.

Front

nested

Back

An escape sequence always begins with a(n) ____.

Front

backslash

Back

Java supports three types of comments: ____, ____, and javadoc.

Front

line, block

Back

Identify the false statement. a. Syntax errors are compile-time errors. b. When you compile a class, you create a new file with the same name as the original file but with a .class extension. c. After you write and save an application, you can compile the bytecode to create source code.

Front

After you write and save an application, you can compile the bytecode to create source code.

Back

Section 3

(40 cards)

A String is an example of an object that can't be changed, also known as _____.

Front

immutable

Back

Which assignment is correct in Java? a. char aChar == 'W'; b. char aChar = 5.5; c. char aChar = '*'; d. char aChar = "W";

Front

char aChar = '*';

Back

Joining Strings with a '+' is called _____.

Front

concatenation

Back

Identify the false statement. a. When you overload Java methods, you write multiple methods with a shared name. b. When you overload Java methods, the methods are called using different arguments. c. Instead of overloading methods, it is preferable to write methods with unique identifiers.

Front

Instead of overloading methods, it is preferable to write methods with unique identifiers.

Back

Which of the following is a floating-point data type that Java supports? a. bit b. double c. single d. scientific

Front

double

Back

Identify the false statement. a. The Character class method isLowerCase() returns the lowercase version of any uppercase character. b. Character is a class, but char is a simple data type. c. If a char variable holds the Unicode value for the Tab key, isWhitespace() would be true and isLetterOrDigit() would be false.

Front

The Character class method isLowerCase() returns the lowercase version of any uppercase character.

Back

If String movie = new String("West Side Story");, the value of movie.indexOf(′s′) is _____.

Front

2

Back

According to the rules of operator precedence, when division occurs in the same arithmetic statement as ____, the division operation always takes place first.

Front

subtraction

Back

Identify the false statement. a. Usually, you want each instantiation of a class to have its own nonstatic data fields, but each object does not need its own copy of most methods. b. When you use a nonstatic method, the compiler accesses the correct object's field because you implicitly pass an object reference to the method. c. The this reference is supplied automatically in classes; you cannot use it explicitly.

Front

The this reference is supplied automatically in classes; you cannot use it explicitly.

Back

The term ____ refers to the mathematical accuracy of a value.

Front

significant digits

Back

The ____ package is implicitly imported into every program you write.

Front

java.lang

Back

The actual length of the _____ is the capacity of the StringBuilder object.

Front

buffer

Back

The Character class is defined in _____.

Front

java.lang

Back

Methods that set or change field values are called ____ methods.

Front

mutator

Back

Identify the false statement. a. A Boolean variable can hold only one of two values—true or false. b. Java supports six relational operators that are used to make comparisons: =, <, >, =<, =>, and =! c. An expression that contains a relational operator has a Boolean value.

Front

Java supports six relational operators that are used to make comparisons: =, <, >, =<, =>, and =!

Back

The assignment operator in Java is ____.

Front

=

Back

The Scanner class contains methods that retrieve values, referred to as ____, from an input device.

Front

tokens

Back

Identify the false statement. a. When you write a constructor, it must have the same name as the class it constructs, and it cannot have a return type. b. In Java, you cannot write a default constructor; it must be supplied for you automatically. c. The automatically supplied default constructor sets all numeric fields to 0, character fields to Unicode '\u0000', Boolean fields to false, and fields that are object references to null.

Front

In Java, you cannot write a default constructor; it must be supplied for you automatically.

Back

A method's ____ is the combination of the method name and the number, types, and order of arguments.

Front

signature

Back

When you perform arithmetic with values of diverse types, Java ____.

Front

implicitly converts the values to a unifying type

Back

The command to execute a compiled Java application is ____.

Front

java

Back

Which of the following is not a commonly used Character method? a. toLowerCase() b. isDigit() c. toUpper() d. isWhiteSpace()

Front

toUpper()

Back

For an alternative to the String class, and so you can change a String's contents, you can use _____.

Front

StringBuilder

Back

Identify the false statement. a. A dialog box is a GUI object resembling a window in which you can place messages you want to display. b. You use an append statement when you want to access a built-in Java class that is contained in a group of classes called a package. c. Different methods can require different numbers of arguments.

Front

You use an append statement when you want to access a built-in Java class that is contained in a group of classes called a package.

Back

To allocate the needed memory for an object, you must use the ____ operator.

Front

new

Back

Identify the false statement. a. Summing a double, int, and float results in a double. b. You can explicitly override the unifying type imposed by Java by performing a type cast; type casting forces a value of one data type to be used as a value of another type. c. When you perform arithmetic operations with operands of unlike types, you must make an explicit conversion to a unifying type.

Front

When you perform arithmetic operations with operands of unlike types, you must make an explicit conversion to a unifying type.

Back

The method that determines whether two String objects are equivalent, regardless of case, is _____.

Front

equalsIgnoreCase()

Back

You use a ____ to explicitly override an implicit type.

Front

type cast

Back

A String variable that does not yet hold a memory address is known as a(n) _____ String.

Front

null

Back

The term that programmers use to describe objects that cannot be changed is _____.

Front

immutable

Back

Objects contain methods and data items, which are also known as ____.

Front

fields

Back

The String class replace() method replaces _____.

Front

every occurrence of a character in a String with another character

Back

The Java ____ contains information about how to use every prewritten Java class, including lists of all the methods you can use with the classes.

Front

API

Back

An object is a(n) ____ of a class, or one tangible example of a class.

Front

instantiation

Back

To create a String object, you can use the keyword _____ before the constructor call, but you are not required to use this format.

Front

new

Back

Nonambiguous, overloaded methods must have the same ____.

Front

name

Back

Identify the false statement. a. Java programs that are embedded in a Web page are called applets, while stand-alone programs are called Java applications. b. Java was developed to be architecturally neutral, which means that anyone can build an application without extensive study. c. After you write a Java program, the compiler converts the source code into a binary program of bytecode.

Front

Java was developed to be architecturally neutral, which means that anyone can build an application without extensive study.

Back

When data cannot be changed while a program is running, the data is ____.

Front

constant

Back

In each Two Truths and a Lie, two of the given statements are true, and one is false. Identify the false statement. a. Unlike a low-level programming language, a high-level programming language allows you to use a vocabulary of reasonable terms instead of the sequences of on and off switches that perform the corresponding tasks. b. Logic errors are fairly easy to find because the software that translates a program finds all the logic errors for you. c. A syntax error occurs when you misuse a language; locating and repairing all syntax errors is part of the process of debugging a program.

Front

Logic errors are fairly easy to find because the software that translates a program finds all the logic errors for you.

Back

Which of the following is not a type of nested class? a. inner b. local c. anonymous d. ambiguous

Front

ambiguous

Back