Preview

Chapter 4 Computer Science Ap Answers

Good Essays
Open Document
Open Document
719 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Chapter 4 Computer Science Ap Answers
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.
4. 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.
9. 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

You May Also Find These Documents Helpful

  • Satisfactory Essays

    PT1420 Chapter 3 Review

    • 1062 Words
    • 8 Pages

    4. Assume the variables result, w, x, y, and z are all integers, and that w = 5, x = 4, y = 8, and z = 2. What value will be stored in result in each of the following statements?…

    • 1062 Words
    • 8 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Pt1420 Unit 1 Lab Report

    • 344 Words
    • 2 Pages

    When given two equations the goal is to make the equations equivalent to one another. These two equations are equivalent. Two equations are known to be equivalent if they have the same solution set. A solution set is a set of numbers that that solve an algebraic equation. In the first equation, the solution set is {5}. In the second solution set both sides of the equation must be equal. Equal means that both sides are balanced. The equality of addition property states that each side of the equal sign must have the exact same numerical value. On both sides, we have a which is the same “number” or “letter”. Since 5 is on one of the sides 5 must be on the other side due to the equality of addition property. That makes x {5}. Finally, because both of their solution sets are {5}, we know that the two equations are equivalent because they have the same solution set.…

    • 344 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    unit 7 assignment 1

    • 431 Words
    • 2 Pages

    1. Why should you indent the statements in the body of a loop? You visually set them apart from the surrounding code.…

    • 431 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Non-Performance - The simplification of the three expressions is either nonexistent or lacks the components described in the assignment instructions.…

    • 300 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Pt1420 Assignment

    • 1058 Words
    • 5 Pages

    1) Initialization: the variable is initialized 2) Test: the loop tests the variable by comparing it to the maximum value 3) Increment: to increase the value during each iteration the loop increments the counter variable by adding 1 to it.…

    • 1058 Words
    • 5 Pages
    Satisfactory Essays
  • Satisfactory Essays

    The variable can be more than one number.. as long as the statement is true…

    • 351 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    unit 8 homework

    • 793 Words
    • 5 Pages

    The advantage of using a sentinel is that when you are processing a long list of values with a loop a sentinel marks the end of a list of items.…

    • 793 Words
    • 5 Pages
    Good Essays
  • Satisfactory Essays

    unit 3

    • 313 Words
    • 2 Pages

    4. Assume the variables result, w, x, y , and z are integers, and that w=5, x=4, y=8, and z=2. What value will be stored in result in each of the following statements?…

    • 313 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    9. A method that stores a value in a class’s field or in some other way changes the value of a field is known as a…

    • 1518 Words
    • 7 Pages
    Good Essays
  • Better Essays

    1) You can call the module several times instead of writing it out each time.…

    • 1580 Words
    • 11 Pages
    Better Essays
  • Satisfactory Essays

    Cosc-2436-73426 Project 2

    • 306 Words
    • 2 Pages

    In order to the function exit with -1 value in case if no result was found, all the items of CheckedA array must be set to true and the count variable must be equal to the number of elements on A (n). Since I is picked randomly and it can be picked multiple times it would have to be E(X) = nlnn +…

    • 306 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    This Is a Paper

    • 469 Words
    • 2 Pages

    The program will terminate because it is expecting an integer value and a “Wingding” will cause an error in the program which will cause it to crash.…

    • 469 Words
    • 2 Pages
    Satisfactory Essays
  • Better Essays

    iv. Names for Java classes follow the same rules as for variable names. It is convention that each word in the class name begins with an upper case letter.…

    • 939 Words
    • 4 Pages
    Better Essays
  • Satisfactory Essays

    Comm 1310 Exam 1

    • 4222 Words
    • 17 Pages

    Message- Written, spoken, and unspoken elements of communication to which people assign meaning. You can send a message intentionally, unintentionally, verbally, nonverbally, or written.…

    • 4222 Words
    • 17 Pages
    Satisfactory Essays
  • Good Essays

    Repetition Structure

    • 885 Words
    • 3 Pages

    In Visual Basic the loop structure will allow you to run one or more lines of code repetitively. In the loop structure you have the ability to repeat statements until the condition is true, false, a specified number of times, or once for each element in a collection. In Visual Basic several problems require repetition capability, in which the sequence or calculation of instructions is repeated over and over using different sets of data. Some examples would include continual checking of user data entries until an acceptable entry i.e a valid password is made. With computer programs the power comes from being able to repeat the same calculation or sequence of instructions several times over each time using different data. It uses different data without having to rerun the program for each new set of data values. Visual Basic has three different types of repetition structures, do while structures, for structures, and do/loop until structures. If it is true the code will be executed and if it is false the cold will not be executed. Statements that initially sets the condition is it must always be placed before the condition is first evaluated to ensure the correct loop execution the first time. Statements within the repeating section of code that allows the condition to become false.…

    • 885 Words
    • 3 Pages
    Good Essays