Hover over the salmon-colored block to see the answer
. | |
This method is used for all of the first three problems:
public int testIt( ) { System.out.print(1); return 2; } What is returned by the method? |
A. 1
B. 2 C. 12 |
B -- 2 |
. | |
What is printed by the method? |
A. 1
B. 2 C. 12 |
A -- 1 |
. | |
What is displayed in the DrJava Interactions pane when this method executes? |
A. 1
B. 2 C. 12 |
A or C The answer was intended to be C (12), but as it happens, if you invoke the methods in the interactions as if it were a statement (i.e., ended by a semicolon), the return value (2) is not displayed. |
. | |
Which is the best description of this line of Java code:
int myIDNumber; |
A. myIDNumber is assigned to int
B. myIDNumber is declared as int C. int is assigned to myIDNumber D. int is declared to be myIDNumber |
B |
. | |
What is the final value of x when this method executes? ("Final
value" of a variable means the value of the variable just as the method
is about to return).
public int ifChecker( ) { int x; x = 0; if (x != 0) { x = 1; } else { if (x <= 5) { x = 2; } else { x = 3; } } return 4; } |
A. 0
B. 1 C. 2 D. 3 E. 4 F. 5 |
C -- 2 |
. | |
What is the value of this Java expression?
3 == 4 || 5 <= 5 |
A. true
B. false C. 3 D. 4 E. 5 |
A -- true |
. | ||
What is the value of this Java expression?
(1 + 2) % (3 + 4) |
A. 0
B. 1 C. 2 D. 3 E. 4 F. 5 |
G. 6 H. 7 I. true J. false K. None of the above -- the answer has a decimal point in it |
D -- 3 |
. | |
In the Paper Street Soap Company problem of Homework #2, which of the following are not classes mentioned in the instructions? Circle as many as apply: |
A. Paper
B. Street C. Soap D. Company E. Wrapper F. Scissors |
B, D, and F. Street, Company, and Scissors are not classes of the problem. |