If an account balance is $1,000 or more, you pay interest. If the balance is less than $100 you
charge a fee. The best way to write this is to : correct answers use two if statements
If s is a String object, which of these relational expressions is illegal (that is, your code will not
compile if you use it) : correct answers s > "Hi"
The second operand used by the conditional operator must have the type : correct answers Any
type is OK
When a selection statement causes a line of code to be executed, that line of code is called :
correct answers a branch
What is the output of the following Java code?
int x = 0;
if (x < 0)
println("One ");
println("Two ");
println("Three"); correct answers Two
Three
Which of the following is a relational operator? correct answers ==
Which of the following is not a selection control structure in Java? correct answers case
Two-way selection in Java is implemented using ____. correct answers if...else statements
In a ____ control structure, the computer executes particular statements depending on some
condition(s). correct answers selection
Which of the following is NOT a relational operator in Java? correct answers <<
According to the online lessons, _________________ are the components used to build OOP
computer programs. correct answers objects
Normally, in an object, the methods are _____________, while the fields are ___________.
correct answers public, private
According to the online lessons, the ________ of an object includes all the information about the
object; that is, its attributes or characteristics. correct answers state
To create a new class by adding features or data elements to an existing class, you use the OOP
technique of correct answers inheritance
, The generic term for methods that carry out an action is a ____________________. correct
answers procedure
Methods like setBackground() that you can use in your own applets are called
____________________ methods. correct answers inherited
When your program first starts, instead of specifying the exact steps to carry out, you can specify
the steps to perform in a general way. Later, you can supply the definition for the general
commands that you've used. This is called: correct answers top-down design
Look at the following few lines of code:
public void printTopHalf()
{
// Statements go here
}
the word printTopHalf is the: correct answers method name
Look at the following few lines of code:
public void printTopHalf()
{
// Statements go here
}
the parentheses following printTopHalf is the: correct answers parameter list
Which modifier is used to specify that a method cannot be used outside a class? correct answers
private
public String exampleMethod(int n, char ch) correct answers String
public int minimum(int x, int y)
{
int smaller = Math.min(x, y);
return smaller;
}
Based on the above code, what would be the output of the statement
int s = minimum(5, minimum(3, 7)); correct answers 3
Which of the following is NOT true about return statements? correct answers return statements
can be used in void methods to return values.