Chapter 3

¡Supera tus tareas y exámenes ahora con Quizwiz!

Q19: In an activity diagram, the merge symbol has the same shape as what other symbol? a) Decision symbol b) Action symbol c) Transition arrows d) Initial state

a) Decision symbol

Q20: Counter-controlled repetition is also known as: a) Definite repetition b) Indefinite repetition c) Multiple-repetition structure d) Double-repetition structure

a) Definite repetition

Q10: A decision symbol in an activity diagram takes the shape of a ________. a) Diamond. b) Rectangle. c) Circle. d) Question Mark.

a) Diamond.

Q22: Where can local variables declared within a method's body be used? a) Only in that method between the line in which they were declared and the closing brace of that method. b) Same as (a), but not within while or if statements. c) Only within while or if statements within the method in which they were declared. d) Anywhere within the class.

a) Only in that method between the line in which they were declared and the closing brace of that method.

Q15: The empty statement is denoted with what symbol? a) Semicolon ; b) Parentheses () c) Braces {} d) End-of-line comment //

a) Semicolon ;

Q9: What is output by the following Java code segment? int temp; temp = 200; if ( temp > 90 ) System.out.println( "This porridge is too hot." ); if ( temp < 70 ) System.out.println( "This porridge is too cold." ); if ( temp == 80 ) System.out.println( "This porridge is just right!" ); a) This porridge is too hot. b) This porridge is too cold. c) This porridge is just right! d) None of the above.

a) This porridge is too hot.

Q28: In an expression containing values of the types int and double, the ________ values are ________ to ________ values for use in the expression. a) int, promoted, double. b) int, demoted, double. c) double, promoted, int. d) double, demoted, int.

a) int, promoted, double.

Q6: Which statement is false? a) Unless directed otherwise, the computer executes Java statements one after the other in the order in which they are written. b) Activity diagrams normally show the Java code that implements the activity. c) Like pseudocode, activity diagrams help programmers develop and represent algorithms. d) The arrows in the activity diagram represent transitions, which indicate the order in which the actions represented by the action states occur.

b) Activity diagrams normally show the Java code that implements the activity.

Q11: Which of the following is not included in an activity diagram for a control structure? a) Transition arrows b) Attribute c) Action state d) Decision symbols

b) Attribute

Q25: Sentinel-controlled repetition is also known as: a) Definite repetition b) Indefinite repetition c) Multiple-repetition structure d) Double-repetition structure

b) Indefinite repetition

Q3: Which of the following is not a benefit of "goto-less programming"? a) Easier to debug and modify b) Shorter c) Clearer d) More likely to be bug free

b) Shorter

Q17: What is output by the following Java code segment? int temp; temp = 180; while ( temp != 80 ) { if ( temp > 90 ) { System.out.print( "This porridge is too hot! " ); // cool down temp = temp - ( temp > 150 ? 100 : 20 ); } // end if else { if ( temp < 70 ) { System.out.print( "This porridge is too cold! "); // warm up temp = temp + (temp < 50 ? 30 : 20); } // end if } // end else } // end while if ( temp == 80 ) System.out.println( "This porridge is just right!" ); a) This porridge is too cold! This porridge is just right! b) This porridge is too hot! This porridge is just right! c) This porridge is just right! d) None of the above.

b) This porridge is too hot! This porridge is just right!

Q24: Which of the following terms is NOT used to refer to a sentinel value that breaks out of a while loop? a) signal value. b) break out value. c) dummy value. d) flag value.

b) break out value.

Q30: Local variables must be ________. a) initialized when they are declared. b) initialized before their values are used in an expression. c) declared and initialized in two steps. d) declared at the top of the method.

b) initialized before their values are used in an expression.

Q8: Which of the following is not a Java keyword? a) do b) next c) while d) for

b) next

Q14: A dangling-else can be clarified by using: a) Indentation b) Parentheses () c) Braces {} d) End-of-line comment //

c) Braces {}

Q29: Which statement is false? a) To ensure that the operands are of the same type, Java performs implicit conversion on selected operands. b) Cast operators are unary operators. c) Cast operators associate from right to left and are one level lower than the multiplicative operators. d) Case operators are formed by placing parentheses around the name of a type.

c) Cast operators associate from right to left and are one level lower than the multiplicative operators.

Q2: Which of the following is true? a) Pseudocode is used to describe an algorithm. b) Pseudocode is translatable by the programmer into a programming language (like Java). c) Pseudocode is used to describe executable statements that will eventually be translated by the programmer into a program. d) All of the above.

c) Pseudocode is used to describe executable statements that will eventually be translated by the programmer into a program.

Q16: Which statement is false? a) Both syntax errors and logic errors are caught by the compiler. b) Both syntax errors and logic errors have effects at execution time. c) Syntax errors are caught by the compiler. Logic errors have effects at execution time. d) Logic errors are caught by the compiler. Syntax errors have effects at execution time.

c) Syntax errors are caught by the compiler. Logic errors have effects at execution time.

Q1: Which of the following is not an algorithm? a) A recipe. b) Operating instructions. c) Textbook index. d) Shampoo instructions (lather, rinse, repeat).

c) Textbook index.

Q12: Which of the following is not true about the conditional operator ( ?: )? a) The conditional operator is a ternary operator, meaning that it takes three operands. b) The first operand is a boolean expression. c) The second operand is the result value if the condition evaluates to false. d) The second operand is the result value if the condition evaluates to true.

c) The second operand is the result value if the condition evaluates to false.

Q13: What is output by the following Java code segment? int temp; temp = 180; if ( temp > 90 ) { System.out.println( "This porridge is too hot." ); // cool down temp = temp - ( temp > 150 ? 100 : 20 ); } // end if else { if ( temp < 70 ) { System.out.println("This porridge is too cold."); // warm up temp = temp + (temp < 50 ? 30 : 20); } // end if } // end else if ( temp == 80 ) System.out.println( "This porridge is just right!" ); a) This porridge is too hot. b) This porridge is too cold. c) This porridge is just right! This porridge is just right! d) None of the above.

c) This porridge is just right! This porridge is just right!

Q18: Which of the following is not an error (either a syntax error or a logic error)? a) Neglecting to include an action in the body of a while statement that will eventually cause the condition to become false. b) Spelling a key word (such as while or if) with a capitalized first letter. c) Using a condition for a while statement that is initially false. d) An infinite loop.

c) Using a condition for a while statement that is initially false.

Q7: Which of the following is a double-selection control statement? a) do...while. b) for. c) if...else. d) if.

c) if...else.

Q5: Which of the following is an action-state symbol? a) diamonds. b) circles. c) rectangles with left and right sides replaced with arcs curving outward. d) rounded rectangles.

c) rectangles with left and right sides replaced with arcs curving outward.

Q21: How many times is the body of the loop below executed? int counter; counter = 1; while ( counter > 20 ) { // body of loop counter = counter + 1; } // end while a) 19. b) 20. c) 21. d) 0.

d) 0.

Q26: Which of the following is not a common name for one of the three phases that a program can be split into using pseudocode? a) Termination phase b) Initialization phase c) Processing phase d) Action phase

d) Action phase

Q4: Which of the following is not a control structure: a) Sequence structure. b) Selection structure. c) Repetition structure. d) Action structure.

d) Action structure.

Q23: Which statement is true? a) Dividing two integers results in integer division. b) With integer division, any fractional part of the calculation is lost. c) With integer division, any fractional part of the calculation is truncated. d) All of the above.

d) All of the above.

Q27: Which of the following segments is a proper way to call the method readData four times? a) double k; k = 0.0; while ( k != 4 ) { readData(); k = k + 1; } // end while b) int i; i = 0; while ( i <= 4 ) { readData(); i = i + 1; } // end while c) int i; i = 0; while ( i < 4 ) { readData(); } // end while

d) int i; i = 0; while ( i < 4 ) { readData(); i = i + 1; } // end while


Conjuntos de estudio relacionados

Сутність маркетингу та його сучасна концепція

View Set

Lippincott Pneumonia, COPD, TB, CHEST TRAUMA, ASTHMA, CARE & SAFETY

View Set

State laws, Rules and Regulations

View Set

Anatomy and Physiology II Unit 3 Exam

View Set

Adult Health 2 Final Exam Study Guide

View Set

AP Human Geography Review - Unit Three

View Set

Data Mining: What is data mining?

View Set

The Cultural Dimensions of Globalization

View Set

CISSP Topic 10 - Physical (Environmental) Security

View Set