Question
What will the value of x be after the following statements are executed? double a, b, c, x; a = 5; b = 3; c
What will the value of x be after the following statements are executed? double a, b, c, x; a = 5; b = 3; c = 6; if ( a <= c ){
x = 1;
} else if ( c > b ) {
x = 2;
} else {
x = 3;
}
A | 0 |
B | 1 |
C | 2 |
D | 3 |
E | 5 |
Question 2
What will the value of x be after the following statements are executed? double a, b, c, x; a = 5; b = 3; c = 6; if ( a <= c ) {
x = 1;
}
if ( c > b ) {
x = 2;
}
if ( x > b ) {
x = 3;
}
A | 0 |
B | 1 |
C | 2 |
D | 3 |
E | 5 |
Question 3
Which of the following is NOT a Java relational operator?
A | = |
B | >= |
C | No answer text provided. |
D | != |
E | > |
Question 4
Which of the following is true?
When using == to compare reference variables, you are testing for "identity equality" -- that the two variables refer to the same object.
The .equals() method tests for "content equality" -- that the objects are considered equivalent to each other.
A | I |
B | II |
C | I & II are both true |
D | Neither is true |
Question 5
What symbols does Java use to create block statements (a 'block' of code)?
A | { } |
B | () |
C | [ ] |
D | No answer text provided. |
Question 6
Which of the following operators may NOT be used with operands of type boolean?
A | && |
B | | | |
C | != |
D | ! |
E | ALL of the above may be used with type boolean |
Question 7
What is a common use for a variable of type boolean?
A | a question variable |
B | a flag variable |
C | a counter variable |
D | a reference variable |
Question 8
What is a common name for a method that returns type boolean?
A | a question method |
B | a flag method |
C | a predicate method |
D | a mutator |
Question 9
Which of the following data types is NOT valid for the switch expression in a switch instruction?
A | int |
B | double |
C | char |
D | all three ARE valid |
E | NONE of these is valid |
Question 10
If a break statement is not included at the end of each action (alternative) in a switchinstruction, what is the result?
A | a syntax error |
B | a run-time exception |
C | no action will ever be executed |
D | more than one action may be executed |
E | no effect -- execution is unchanged |
Question 11
The switch instruction is a more general-purpose (more versatile) tool than the ifinstruction.
A | True |
B | False |
Question 12
You are writing a program that will allow a user to enter a single word identifying her 'sign' in the Chinese zodiac (e.g. "Dog") and then show some information about that sign. Obviously a decision must be made in this program. Which selection structure(s) could you use?
A | if statements should be used |
B | a switch statement should be used |
C | either if statements or a switch statement could be used |
Question 13
What numerical value for x will cause the following expression to evaluate to true. x > 5 || x < 9
A | x = 3 |
B | x = 7 |
C | x = 12 |
D | NO value of x -- all numerical values cause the expression to evaluate to false |
E | ALL numerical values cause the expression to evaluate to true |
Question 14
Which of the following is a legal Java expression?
A | 2 <= n < 5 |
B | 2 <= n && < 5 |
C | 2 <= n && n < 5 |
D | 2 <= n && !5 |
Question 15
Which of the following operators has the highest precedence?
A | | | |
B | No answer text provided. |
C | && |
D | > |
E | % |
Question 16
Which of the following is true in Java? I. Every else must have a preceding if. II. Every if must have a following else.
A | I. |
B | II. |
C | I & II are both true |
D | Neither are true |
Question 17
What kind of loop is a data validation loop?
A | a definite loop |
B | an indefinite loop |
Question 18
Which loop control structure can NOT be used if there are conditions under which the body of the loop should be executed zero times?
A | for |
B | while |
C | do...while |
D | Any of the loop control structures can be used in this situation. |
E | None of the above -- this situation is impossible to program. |
Question 19
You know that a for loop is usually the best choice for a counting loop, but which other loop control structure(s) could possibly be used to create a counting loop?
A | a while loop |
B | a do...while loop |
C | any of the loop control structures can be used to create a counting loop |
D | none of the above -- only a for loop can be used |
Question 20
Consider the following class definition:
public class Woog{
public static void main (String[] a){
Fiddle f = new Fiddle();
...
}
}
How would you describe the relationship between Fiddle and Woog?
A | Fiddle is the client class. Woog is the supplier class. |
B | Woog is the client class. Fiddle is the supplier class. |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started