AP Computer Science: Mid-Term – Flashcards

Unlock all answers in this set

Unlock answers
question
____ parameters are variables in a method declaration that accept the values from the actual parameters
answer
formal
question
When an object of one class is a data field within another class, they are related by _____.
answer
composition
question
A locally declared variable always ____ another variable with the same name elsewhere in the class.
answer
masks
question
It is illegal to declare the same variable name more than once within a block
answer
True
question
Application classes frequently instantiate objects that use the objects of other classes
answer
True
question
It is not necessary to create an instance of the Math class because the constants and methods of the class are ____
answer
static
question
A(n) ____ method is a method that creates and initializes class objects constructor.
answer
constructor
question
When calling this() from a constructor, it must be the ____ statement within the constructor
answer
first
question
A(n) ____ is a program module that contains a series of statements that carry out a task
answer
method
question
You are ____ required to write a constructor method for a class
answer
never
question
The ____ method executes first in an application, regardless of where you physically place it within its class
answer
main()
question
The reference to an object that is passed to any object's nonstatic class method is called the ____
answer
this reference
question
You can leave out the ____ statements in a switch structure
answer
break
question
____ is the encapsulation of method details within a class
answer
implementation hiding
question
You can use the ____, which is written as ||, if you want some action to occur when at least one of two conditions is true
answer
conditional OR operator
question
In the switch structure, break is followed by one of the possible values for the test expression and a colon
answer
False
question
A ____ checks a value, and based on the result performs one of two actions
answer
decision structure
question
The ____ statement notifies the program that you will be using the data and method names that are part of the imported class or package
answer
import
question
Within any class or method, the code between a pair of curly braces is called a(n) ____
answer
block
question
A(n) ____ statement is the decision structure you use when you need to take one or the other of two possible courses of action
answer
dual-alternative if
question
When you use nested if statements, you must pay careful attention to placement of any else clauses
answer
True
question
Public classes are accessible by all objects, which means that public classes can be ____, or used as a basis for any other class
answer
extended
question
When you write your own constructors, you cannot write versions that receive parameters
answer
False
question
A(n) ____ constructor is one that requires no arguments
answer
default
question
In order to allocate memory for an object, you use the ____ operator
answer
new
question
A ____ consists of written steps in diagram form, as a series of shapes connected by arrows
answer
flowchart
question
An application's main() method must have a void return type
answer
True
question
The ____ statement is useful when you need to test a single variable against a series of exact integer, character, or string values
answer
switch
question
Object-oriented programmers use the term ____ when a child class contains a field or method that has the same name as one in the parent class
answer
override
question
As long as you do not make any ambiguous method calls, a program that contains a potentially ambiguous situation will execute correctly
answer
True
question
An object is a ____ of a class
answer
member
question
A(n) ____ is a series of if statements that determine whether a value falls within a specified range
answer
range check
question
Just as you can block statements that depend on an if, you can also block statements that depend on a(n) ____
answer
else
question
Any class can contain an unlimited number of methods
answer
True
question
You can use the asterisk (*) as a ____, which indicates that it can be replaced by any set of characters
answer
wildcard symbol
question
When writing a statement with the two-line format, you must be sure to type a semicolon at the end of the first line in order to ensure accurate results
answer
False
question
When a variable ceases to exist at the end of a method, programmers say the variable ____
answer
goes out of scope
question
____ variables are variables that are shared by every instantiation of a class
answer
Class
question
Which of the following is NOT an initial value assigned to an object's data field by a default constructor? a field of object references set to null
answer
Boolean fields set to true
question
If you give the same name to a class's instance field and to a local method variable, the instance variable overrides the method's local variable
answer
False
question
You can use ____ arguments to initialize field values, but you can also use arguments for any other purpose
answer
constructor
question
Although it is possible to block statements that depend on an if, you cannot likewise block statements that depend on an else
answer
false
question
A(n) ____ variable is known only within the boundaries of the method instance
answer
local
question
If an integer is passed to a method with a double parameter, the double is promoted to an integer
answer
false
question
A disadvantage of Java is the large memory requirements to store a separate copy of each variable and method for each instantiation of a class
answer
false
question
An alternative to using a Boolean expression, such as someVariable == 10, is to store the Boolean expression's value in a Boolean variable
answer
True
question
When you properly ____ a method, you can call it providing different argument lists, and the appropriate version of the method executes
answer
overload
question
The method ____ is the first line of a method
answer
declaration
question
When working with logical operators, you can always use ____ to change precedence
answer
parentheses
question
When using equals and not equals for comparisons with objects, you compare the objects' ____ instead of actual values
answer
memory addresses
question
You can use the keyword final with methods or classes
answer
True
question
When you create a block, you must place multiple statements within it
answer
false
question
When you execute an if...else statement, only one of the resulting actions takes place depending on the evaluation of the ____ following the if
answer
Boolean expression
question
When they have the same name, variables within ____ of a class override the class's fields
answer
methods
question
A variable comes into existence, or ____, when you declare it
answer
comes into scope
question
The keyword ____ indicates that a field value is unalterable
answer
final
question
When a value is returned from a method, you are required to use the value when the method is called
answer
false
question
The ____ operator is always evaluated before the OR operator
answer
and
question
The name of the ____ is always the same as the name of the class whose objects it creates
answer
constructor
question
When an expression containing a ____ is part of an if statement, the assignment is illegal
answer
single equal sign
question
Methods used with object instantiations are called ____ methods
answer
instance
question
The ____ package contains frequently used classes and is implicitly imported into Java programs
answer
java.lang
question
If a class's only constructor requires an argument, you must provide an argument for every ____ of the class that you create
answer
object
question
The AND operator is written as two ____
answer
ampersands
question
Methods that retrieve values are called ____ methods
answer
accessor
question
The ____ operator is written as the exclamation point ( ! )
answer
not
question
A method's identifier must be more than one word, must have no embedded spaces, and cannot be a Java keyword
answer
false
question
When an application contains just one version of a method, you can call the method using a(n) ____ of the correct data type
answer
parameter
question
Due to automatic type promotion, when a method with a double parameter is passed an integer, the integer will be promoted to a(n) ____
answer
double
question
You can identify a class that is an application because it contains a public static void main() method
answer
True
question
A(n) ____ causes a value to be sent from a called method back to the calling method
answer
return statement
question
When you block statements, you must remember that any ____ you declare within a block is local to that block
answer
variable
question
A block can exist entirely within another block or entirely outside and separate from another block, and sometimes blocks can overlap
answer
false
question
Statements in which an if structure is contained inside another if structure are commonly called ____ if statements
answer
nested
question
When you place a block within an if statement, it is crucial to place the ____ correctly
answer
curly braces
question
A method can receive ____ arguments, even if it is defined as needing double arguments
answer
integer
question
____ involves using one term to indicate diverse meanings, or writing multiple methods with the same name but with different parameter lists
answer
overloading
question
Parentheses in a method declaration contain parameters that are funneled into the method
answer
True
question
The compiler determines which version of a method to call by the method's ____
answer
signature
question
When you instantiate an object from a class, ____ is reserved for each instance field in the class
answer
memory
question
An alternative to importing a class is to import an entire package of classes
answer
True
question
Range checking and the switch statement are tools programmers can use for effective decision making
answer
True
question
Although not required, it is common procedure to align the keyword if with the keyword else
answer
True
question
Failing to include a complete ____ on each side of an && operator in an if statement is a common error in Java programming
answer
Boolean expression
question
Data items you use in a call to a method are called ____
answer
arguments headers
question
The simplest statement you can use to make a decision is the ____ statement
answer
if
question
The compiler does not take indentation into account when compiling code, but consistent indentation can help readers understand a program's ____
answer
logic
question
It is a convenience to be able to use one reasonable name for ____ that are functionally identical except for argument types
answer
tasks
question
A logical structure called a(n) ____ structure is when one step follows another unconditionally
answer
sequence
question
The arguments in a method call are often referred to as ____
answer
actual parameters
question
The ____ requires three expressions separated with a question mark and a colon
answer
conditional operator
question
You write pseudocode in everyday language, not the syntax used in a programming language
answer
True
question
When you overload a Java method, you write multiple methods with a shared name
answer
True
Get an explanation on any task
Get unstuck with the help of our AI assistant in seconds
New