Chapter 12 Flashcards

1
Q

What is a while statement and how does it work?

A

A while statement has a condition and based off of its condition will perform its statements over and over until the statement does not match the input for the condition. It acts as a loop until it does not match the input

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is another name for a while statement?

A

Another name for a while statement is a while loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the stuff inside the curly braces in a while statement and what does it do?

A

The stuff inside the cooley braces repeats itself until it matches the input of the while statements conditions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is it called every time the while statement loops?

A

It is called an iteration of the loop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a while statement similar to?

A

It is similar to an if statement as an executes what is in the curly braces if it matches the input but it loops it over and over again and that’s what’s the difference between an if statement and a while statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What elements can be used in both and if statement and a while statement within the curly braces?

A

You can write out statements to create a block statement which is more than one statement within the curly braces

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is an infinite loop?

A

it’s a continuing of the running of code that won’t stop producing text in the console view.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

how do you stop a program dead in it’s tracks so that it doesn’t continue to run?

A

there is a small rectangular red square at the top of Eclipse’s Console view. as you hover your mouse above it, the tooltip says Terminate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

in which cases is an infinite loop suitable?

A

code with an infinite loop is beneficial in air traffic control, the monitoring of a heart lung machine etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

how do you create a perfect tab indentation in a call to print?

A

using “\t” creates a tab of indentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what is a tab using “\t” or “\n” for bringing the cursor to a new tab called?

A

these are called escape sequences

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

how else can you bring the cursor to a newline without using System.out.println in your code?

A

you can use System.out.print(“ \n “)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

what are the 3 steps in order, when creating loops that contain a random number for input and what is the correct first step to take and why?

A

first you need to initialize; set up intial values if needed

2nd; test condition; check if the random number meets the stopping condition

3rd; random input; Generate a new random number each time the loop runs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what is priming the loop?

A

means setting up a condition so that the loop can run correctly from the start.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

how many steps is there when priming a loop without a random number for the input? and what is the correct order?

A

Initialize (Prime the Loop): Get the first input before the loop starts.

Test Condition: Check if number is valid for continuing the loop.

Process (Print): Do something with the input (like print it).

Input (Update): Update the variable at the end of each iteration.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
A