Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Which of the following is the first step in the problem-solving phase of a compu

ID: 3724575 • Letter: W

Question

Which of the following is the first step in the problem-solving phase of a computer program’s life cycle?

Flag this Question

Question 21 pts

In Java, a single character such as the letter A usually is stored as a:

Flag this Question

Question 31 pts

Suppose that alpha and beta are int variables. The statement alpha = --beta; is equivalent to the statement(s) ____.

beta = beta - 1;

alpha = beta;

beta = beta - 1;

alpha = 1 - beta;

beta = beta - 1;

alpha = beta - 1;

alpha = beta;

beta = beta - 1;

Flag this Question

Question 41 pts

Suppose x = 4 and y = 2. If the statement

    x *= y;

is executed once, what is the value of x?

Flag this Question

Question 51 pts

Which of the following is a valid statement?

(i) int num = new int(67);

(ii) String name = new ("Doe");

(iii) String name = "Doe";

Flag this Question

Question 61 pts

Suppose that you have the following declaration:

int num = 94;
double x = 73.92;
String str = "Programming";

What is the output of the following statements?

System.out.println("123456789012345678901234567890");

System.out.printf("%5d%6.2f %15s%n", num, x, str);

123456789012345678901234567890

94     73.92   Programming

123456789012345678901234567890

94 73.92     Programming

123456789012345678901234567890

94 73.92   Programming

123456789012345678901234567890

94 73.92 Programming

Flag this Question

Question 71 pts

A Java identifier cannot start with a digit.

Flag this Question

Question 81 pts

The Java compiler considers the identifier CanOfWorms to be the same as the identifier canofworms.

Flag this Question

Question 91 pts

Java reserved words are all in lowercase. When can some of them also be used “as-is” as programmer-defined identifiers?

Flag this Question

Question 101 pts

In Java, a {} block (or compound statement) is terminated by a semicolon.

Flag this Question

Question 111 pts

A literal is always a string of numbers.

Flag this Question

Question 121 pts

Which of the following statements about the Java main function is false?

Flag this Question

Question 131 pts

Which of the following cannot be assigned to a char variable?

Flag this Question

Question 141 pts

Which assignment statement could be used to store the letter A into the char variable someChar?

A) someChar = "A";

C) someChar = 'A';

B) someChar = A;

Flag this Question

Question 151 pts

In Java, the phrase "System.out" usually refers to:

Flag this Question

Question 161 pts

In a Java function, the statements enclosed by a { } pair are known as a

____________________ of code.

Flag this Question

Question 171 pts

A(n) ____________________ is an identifier that references a location in memory in which a data value that can be changed is stored.

Flag this Question

Question 181 pts

Suppose that x is an int variable. Which of the following expressions always evaluates to false?

Flag this Question

Question 191 pts

Based on the code above, which part of the following expression is not evaluated?

('A' < 'a') && (4 <= 8) || (2.5 >= 7) || (4 < y)

4 < y

2.5 >=7 || 4 < y

4 <= 8

Flag this Question

Question 201 pts

In Java, the name of the source file is also the ____________________.

Flag this Question

Question 211 pts

In Java, multiple assignment statements are evaluated from right to left.

If the initial value of the integer x is 5 and integer y is 3, the statement

x %= y += --x + y;

results in ________________ for x. (% is the modulus operator.)

Flag this Question

Question 221 pts

Analyze the following code:

// Enter an integer

String numString = JOptionPane.showInputDialog(null,

   "Enter a number:",

   "Exam Input", JOptionPane.QUESTION_MESSAGE);

int number = Integer.parseInt(numString);

if (number <= 0) ;

else

   System.out.println(number);

Flag this Question

Question 231 pts

What is the output of the following code:

int x = 9;
int y = 8;
int z = 7;
if (x == 9) ;

if (y > 8)
System.out.println("One");
else if (z >= 7)
System.out.println("Two");
else
System.out.println("Three");

Flag this Question

Question 241 pts

If someInt is a variable of type int, the statement

         someInt = (float) 395;

causes someInt to contain an floating-point rather than an integer value.

Flag this Question

Question 251 pts

What is the output of the following code:

int x = 9;
int y = 8;
int z = 7;

if (x > 9)
if (y > 8)
System.out.println("One");
else if (z >= 7)
System.out.println("Two");
else
System.out.println("Three");

Flag this Question

Question 261 pts

If testScore is an int variable containing the value 78, which output statement will produce the following output:

1234567890

Score: 78

Flag this Question

Question 271 pts

The value of the Java expression 11 + 22 % 4 is:

Flag this Question

Question 281 pts

The value of the Java expression 3 / 4 * 5 prior to being stored in a double variable is:

Flag this Question

Question 291 pts

What is the output of the following Java code?

int alpha = 5;
int beta = 4;

switch (beta) {
case 2:
alpha = alpha + 2;

case 4:
alpha = alpha + 4;
break;

case 6:
alpha = alpha + 6;

default:
alpha = alpha + 10;
}
System.out.print(alpha);

Flag this Question

Question 301 pts

For the code in the previous question, what is output if beta = 6?

Translate the general solution into code.

Explanation / Answer

11. Analyze the problem.

21. char

31. beta = beta - 1; alpha = beta;

41. 8

51. only (iii)

61.123456789012345678901234567890

94 73.92 Programming

71. true

81. false

91. Java reserved words are keywords that are reserved by Java functions or other uses that cannot be used as identifiers (e.g., variable names, function names, class names). If a reserved word was used as a variable you would get an error or unexpected result.

10. false

111. false

121. The main function must call (invoke) at least one other function.

131. "$"

141. C) someChar = 'A';

151. the display screen

161. Block

171. Variable

181. (x > 0) && ( x <= 0)

191. 4 < y

201. class name

211. 5

221. If number is greater than zero, number is displayed

231. two

241. false

251. Since the second if condition is inside the first one and value of x is not greater than 9, nothing will be printed.

261. B and C

271. 13

281. 0

291. 9

301. 21

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote