Final Exam Flashcards
Every class definition must include a constructor.
True
False
False
While multiple objects of the same class can exist, in a given program there can be only one version of each class.
True
False
True
A method defined in a class can access the class’ instance data without needing to pass them as parameters or declare them as local variables.
True
False
True
Accessors and mutators provide mechanisms for controlled access to a well-encapsulated class.
True
False
True
All Java classes must contain a main method which is the first method executed when the Java class is called upon.
True
False
False
In Java, the symbol “=” and the symbol “==” are used synonymously (interchangeably).
True
False
False
As in the other members of the C family of languages (C, C++, C#), Java interprets a zero value as false and a non-zero value as true.
True
False
True
In Java, selection statements consist of the if and if-else statements.
True
False
False
When comparing any primitive type of variable, == should always be used to test to see if two values are equal.
True
False
False
The statement if (a >= b) a++; else b–; will do the same thing as the statement if (a < b) b–; else a++;.
True
False
True
An if statement may or may not have an else clause, but an else clause must be part of an if statement.
True
False
True
In order to compare int, float and double variables, you can use , ==, !=, <=, >=, but to compare char and String variables, you must use compareTo( ), equals( ) and equalsIgnoreCase( ).
True
False
False
Control in a switch statement jumps to the first matching case.
True
False
True
Each case in a switch statement must terminate with a break statement.
True
False
False
It is possible to convert any type of loop (while, do, or for) into any other.
True
False
True
The following loop is syntactically valid.
for (int j = 0; j < 1000; j++) j--;
True
False
True
Given the following assignment statement, which of the following answers is true regarding the order that the operators will be applied based on operator precedence?
a = (b + c) * d / e - f; A) *, /, +, - B) *, +, /, - C) +, *, /, - D) +, /, *, - E) +, -, *, /
C
For the questions below, assume that boolean done = false, int x = 10, int y = 11, String s = “Help” and String t = “Goodbye”.
The expression (!done && x <= y) is true.
True
False
True
A dialog box is a device which accepts voice commands.
True
False
False
For the questions below, assume that boolean done = false, int x = 10, int y = 11, String s = “Help” and String t = “Goodbye”.
The expression (done | | s.compareTo(t) < 0) is true.
True
False
False
If a language uses 240 unique letters and symbols, how many bits would be
needed to store each character of a document?
a. 1
b. 3
c. 7
d. 8
e. 2
D
Which of the following is not valid Java identifier?
a. Factorial
b. level2
c. hook&ladder
d. highest$
C
Categorize the following as a compile-time error, run-time error, or logical error.
Q6.Multiplying two numbers when you meant to add them
a. logical error
b. run-time error
c. compile-time error
A
Categorize the following as a compile-time error, run-time error, or logical error.
Q6.Multiplying two numbers when you meant to add them
a. logical error
b. run-time error
c. compile-time error
A
Producing inaccurate results
a. logical error
b. run-time error
c. compile-time error
A
Typing a { when you should have typed (
a. logical error
b. run-time error
c. compile-time error
C