Chapter 3 Flashcards

(24 cards)

1
Q

Precedence of arithmetic vs equality and relational operators?

A

Arithmetic operators are higher

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

Example of a unary operator

A

NOT (!) because it operates on 1 operand

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

Example of binary operators

A

AND and OR because each operates in two operands

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

Precedence of logical operators vs relational operators

A

Logical operators have a lower precedence

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

Logical operator precedence

A

NOT AND OR

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

Which statement checks only once

A

If statement or if else statement

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

Conditional operator example

A

System.out.print(“your change is “ +count+ ((count ==1)? “Dime” : “Dines”));

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

Statement that evaluates and expression then attempts to match the result to one of several possible cases

A

Switch statement

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

Statement used to control and go to the end o the switch statement

A

break;

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

Switch statement example

A
switch(option) {
case 'A':
  ACount++;
  break;
case 'B'
  BCount++;
  break;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

The case in which the control will transfer to it if no other case matches the value

A

default case

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

Switch Statement rules

A

Only have an integral type(byte, short, int, long) or char
Not be a Boolean or float or double
Implicit Boolean condition in switch statement is equality
No relational checks with a switch statement

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

Comparing strings

A
compareTo
name1.compareTo(name2);
Zero means equal 
Neg means name1 is less than name2
Pos means name1 is greater than name2
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Lexicographic ordering

A

Uppercase come before lower case

Short strings come before longer strings

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

A statement that executes continuously until the condition becomes false

A

while loop

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

While loop syntax

A

while(condition)

statement;

17
Q

What can be used to maintain a running sum?

18
Q

A special input value that represents the end of input

A

Sentinel Value

19
Q

A statement that is executed once initially and then the condition is evaluated

A

The do Statement

20
Q

Syntax for the for statement

A

for(initialization; condition; increment)

statement;

21
Q

Loop used for a specific number of times that can be calculated in advance

22
Q

Infinite for loop

23
Q

For loop rules

A

Initilzation left out none is performed
Condition left out means always true
Increment left out means no increment operation performed

24
Q

Syntax for a if statement

A
If a Java reserved word 
Condition must be a Boolean expression 
Statement
If(condition)
Statement;