CP Chapter 5 Review.1

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

In a switch structure, what symbol separates the selection constant from the program statement that needs to be performed if a match is found.

( : ), semicolon

How do you control multiple program statements with one-way or two-way selection?

Block structure

How do you repeat multiple statements with the for loop structure?

Block structure

How do you control multiple statements with switch?

Cases

What do Selection and Repetition control structures have in common?

Change of program flow

Explain Repetition

Control structure that executes certain program segments repeatedly

What library is the Scanner class located in?

standard Java classes

Assume the condition for a while loop is already false, even before the loop begins.How many times will the loop execute?

0

Java does not use "=" to test for equality? What does it use instead? ==

==

How does Simple Sequence work?

A series of program statements are executed in the exact sequence that they are written.

Programs in what computer language require control structures?

Any language

While program Java0505.java compiles and executes, its output is strange. How does program Java0506.java fix the problem?

By adding break to every statement

Selection control structures use a special _____________ statement

Conditional

What are 2 synonyms for Selection?

Conditional branching or decision making

What kind of loop is the while loop?

Do...while loop

A for loop is not well suited for something like entering a password. Both the while loop and the do...while loop would work in this case. If you were writing a password program, which loop structure would you chose? Explain the reasoning behind your answer.

Do...while loop because you can keep trying until the correct statement is put in

List the 6 relational operators

Equals, not equals, greater than, less than, greater than or equal, and less than or equal

Which repetition control structures are covered on the AP® Computer Science Exam?

Fixed -repetition, pre-condition

What loop structure is used with fixed iteration?

For

Which loop structure would be good if you wanted to display 50 rectangles on the screen?

For

What is the main concern in using graphics commands with control structures?

Graphic displays are not simply a matter of calling the right method for the right purpose.

What statement is used with if for two-way selection?

If ... else

In one-way selection, when does the program flow branch off?

If the condition is true

Write the Java statement that will do this action:

If your grade is 70 or better, print "You passed!" otherwise print "You failed!" System.out.print("Enter your grade score. --> "); int sat = input.nextInt(); System.out.println(); if (sat >= 70) System.out.println("You passed!"); else System.out.println("You failed!");

What does the j++ mean?

Indicates the manner in which the Loop Control Variable is altered. In this case the value of k is incremented by 1 each time through the loop.

What must happen inside a while loop?

Initialize condition variable

What does the j = 1 mean?

Initializes the Loop Control Variable. means that j starts with the value of 1

What data types work with switch?

Int, char and String

What is the benefit of using loop control structures with graphics?

Its way easier to draw it then to go one-by-one

What kind of operator is "="?

Java relational operators

What is the only thing checked in a while loop?

Loop condition

What does LCV stand for?

Loop entry variable

With switch, can multiple cases yield the same result?

Looping, iteration

Explain how Multi-way Selection is accomplished in Java.

Multi-way selection is accomplished with the switch command which uses a selection variable with a value. The selection variable value is compared with a group of designated case values. When a match is found, the statements following the case value are executed.

Does Multi-way Selection use a conditional statement?

NO

Why is a prompt necessary for program input?

Needs to be used to indicate what type of information must be entered at the keyboard

What would be the output of program Java0506.java if 0 were entered?

Nothing, error message

Where must the loop counter be initialized when using a while loop?

On top of the loop body

Assume the condition for a do...while loop is already false, even before the loop begins.Furthermore, assume nothing in the loop will ever make the condition change to true.How many times will the loop execute?

Once

Which selection control structures are covered on the AP® Computer Science Exam?

One-way, two-way

What are the 3 types of Selection?

One-way, two-way and multiple-way

What would be the output of program Java0506.java if 9 were entered?

Only "September"

All conditions must be placed inside what?

Parentheses

What is a conditional statement?

Program expression, which evaluates to true or false

Most conditional statements will require what?

Relational operator

What kind of operator is required to make an expression evaluate to true or false?

Relational operator

What would you need to change in program Java0507.java if Joe wanted the message displayed 1000 times?

Replace "60" with "100" in the loop control condition

In two-way selection, what happens if the condition is false?

Selects one direction, or the other direction, but not both

What are the 3 general types of control structures?

Simple sequence, selection, repetition

What does the j <= 100 mean?

States the Loop Entry Condition. As long as the value of j is less than or equal to 100, the program statement following the for parenthesis will be executed

In fixed iteration, what does fixed mean?

That the number of times that a program segment repeats, is fixed

Why is the do...while loop called a post-condition loop?

The body of the loop is placed between the starting do keyword, and the closing while condition. Since the condition of the loop exit is tested at the conclusion of the loop body

What does program flow follow?

The exact sequence of listed program statements, unless directed otherwise by a java control structure

In one-way selection, what happens if the condition is false?

The program flow continues without change in the program sequence

The while loop structure requires a statement inside the loop body that was not necessary with the for loop. What is the purpose of this statement?

The purpose of this statement is to give an opportunity for the loop control variable to change

Explain Multiple-Way Selection.

There is a special selection variable that is used along with several selection constants. The selection variable is compared with each selection constant until a match is found. The condition that you do not really see is if the selection variable equals a particular selection constant

What is the essence of understanding, and using, control structures?

Understanding conditional statements

What would be the output of program Java0505.java if 9 were entered?

When 9 is entered we see "September" and everything after it

When is the default statement executed?

When nothing is specified

What does the nextInt method do?

Will stop the program execution and then sit still patiently waiting for the input of an integer value from the keyboard

Must the loop counter in a for statement be an int?

Yes

Which control structure is used in the most with graphics programs in this chapter?

drawLine

Give a real life situation where fixed iteration is not practical.

the entry of a password can be correct the first time or it may take many repeated attempts before the correct password is entered.


Conjuntos de estudio relacionados

Module:Priority Setting Frameworks

View Set

GLG 111 Final Practice Questions

View Set

Chapter 16: The Endocrine System

View Set

ABC UNIT 1 basic study of canines

View Set

Module 8 - Sleep and Dreams - Quiz #2

View Set

L4M6 Supplier Relationships all chapters revision

View Set