Chapter 4 Computer Science Ap Answers Essay

Lesson 4 – introduction to control statements Fill in the Blanks Complete the following sentences by writing the word or words in the blanks provided. 1. In the statement, x =3;, the ‘ =’ operator is one of Java’s extended assignment operators. 2. Using the same name for two methods in the same class, where each method has different parameter input, is called overloading. 3. The nextInt method of Java’s Random class returns an integer chosen at random from a range of values between 0 and n-1 where n is the parameter value passed to the method. . Java’s while statement, and the if-else statements are examples of control statements. 5. The double equal sign (==) is the symbol used to represent Java’s equal to operator. 6. Java’s for loop is an example of a(n) counter-controlled loop. 7. When a while loop or a for loop is coded inside another while loop or for loop, the inner loop is called a(n) nested loop.. 8. A(n) sentinel is a special value that denotes the end of a list and is used to terminate loop processing when reading input values from a user, or a data file. . A(n) off-by-one error occurs when a loop is executed one too many, or one too few times due to an incorrectly coded check of the counter variable. 10. A loop that runs without stopping due to a logic error is called a(n) infinite loop 11. Using a floating-point value as a control variable in a loop, but failing to account for the effects of floating-point precision, can cause a loop to execute much differently than expected. True/False Circle T if the statement is true or F if the statement is false. T F 1.

Using Java’s increment and decrement operators in the middle of complex expressions might lead to programming errors due to complexities involved in using these operators. T F 2. Java’s max() method returns the maximum value possible for a variable of the supplied data type.. T F 3. Java’s read messages can be passed text strings as a parameter, and the string will be used by the method as a prompt for the read operation. T F 4. An opening and a closing brace is required for all code statement(s) inside the if or if-else statements.

We will write a custom essay sample on
Chapter 4 Computer Science Ap Answers
specifically for you for only $13.9/page
Order now

T F 5. The Java statement, x = a < b < c; will return a value of true to x if a is less than b and b is less than c. T F 6. The counter in a for loop is updated at the top of the loop, before executing any of the statements within the loop. T F 7. The counter variable for a for loop can be declared inside the loop header, and the same name can be used in other loops in the program as long as it is declared inside the loop header every time. T F 8.

If a counter variable for a loop is declared inside the loop header, the variable is visible to all code within the method where the loop is declared, but not visible outside that method. T F 9. An initialization error occurs when a loop is begun before its counter or some other variable within the loop has been set to some specified starting value. T F 10. If a program on your PC goes into a never-ending loop, the best thing to do is turn off the PC’s power switch. T F 11. Omitting or coding extra brace symbols ({ } ) within a loop can cause unexpected results when the loop is executed.

Multiple choice Select the best response for the following statements. 1. The abs() method and the round() method are members of which Java class? a. Arith. b. Math. c. Mathops. d. None of the above. 2. A message is sent to the method’s class instead of to an object if the method’s signature is labeled ____ a. private. b. local. c. static. d. public. 3. The condition specified for an if or an if-else statement must be a(n) _____ expression. a. Boolean b. Arithmetic c. Relational d. Assignment 4. Which term below best describes the ;= and the

Haven’t Found A Paper?

Let us create the best one for you! What is your topic?

By clicking "SEND", you agree to our terms of service and privacy policy. We'll occasionally send you account related and promo emails.

Eric from Graduateway Hi there, would you like to get an essay? What is your topic? Let me help you

logo

Haven't found the Essay You Want?

Get your custom essay sample

For Only $13.90/page