the java Essay

4111 Words17 Pages
Java Software Solutions: Foundations of Program Design, 6e (Lewis/Loftus) Chapter 5 Conditionals and Loops Multiple-Choice Questions 1) The idea that program instructions execute in order (linearly) unless otherwise specified through a conditional statement is known as A) boolean execution B) conditional statements C) try and catch D) sequentiality E) flow of control Answer: E Explanation: E) The "flow of control" describes the order of execution of instructions. It defaults to being linear (or sequential) but is altered by using control statements like conditionals and loops. 2) Of the following if statements, which one correctly executes three instructions if the condition is true? A) if (x < 0) a = b *…show more content…
So the logic is improper. If the student's grade falls into the 'A' category, then all 4 conditions are true and the student winds up with a 'D'. If the student's grade falls into the 'B' category, then the first condition is false, but the next three are true and the student winds up with a 'D'. If the student's grade falls into the 'D' category, then the only condition that is true is the one that tests for 'D' and so the grade is assigned correctly. If the student's grade falls into the 'F' category, then none of the conditions are true and an 'F' is assigned correctly. So, only if the grade < 70 does the code work correctly. 8) You might choose to use a switch statement instead of nested if-else statements if A) the variable being tested might equal one of several hundred int values B) the variable being tested might equal one of only a few int values C) there are two or more int variables being tested, each of which could be one of several hundred values D)

More about the java Essay

Open Document