Unit 2 Exam Flashcards

1
Q

3 types of methods

A

boolean methods, a method that calculates something, input/output methods

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

ternary operator (?:)

A

a shorter way of writing an if…else
boolean expression ? what to return if true : what to return if false

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

<=

A

less than or equal to

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

continue

A

only works in loops
jumps back to the boolean expression

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

random number generation

A

(int) (Math. random() * (max - min + 1)) + min

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

!=

A

not equal to

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

> =

A

greater than or equal to

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

what variable types CAN’T be used with switch

A

CANNOT USE SWITCH ON FLOATS, LONGS, OR DOUBLES DUE TO ROUND-OFF
also cannot be used on boolean

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

method parameters

A

parameters allow for data to be passed through
separated by commas

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

what is a boolean expression

A

evaluates true or false

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

||

A

returns true if either is true

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

switch statements

A

must have a single variable and care about multiple specific values of it
when you have a variable with a known list of values to compare to

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

precedence

A

+ -
<, >, <=, >=
==, !=
&&
||

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

what happens if case above default doesn’t have a break

A

IF THE CASE ABOVE THE DEFAULT DOES NOT CONTAIN A BREAK, WILL RUN THE CODE IN THE DEFAULT AS WELL

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

what happens if a case doesn’t have a break

A

WITHOUT BREAK THE SWITCH WILL PRINT ALL OPTIONS BELOW

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

!

A

returns the opposite of

17
Q

execute method

A

invoke, run, or call from another method

18
Q

return

A

ends a method

19
Q

boolean methods

A

contains no SOP, Scanner (no user input/output)
makes a decision and returns true or false

20
Q

returning data with methods

A

change void to the type of data that needs to be returned
if a method has a non-void return type, must be saved or printed or else the value lost
using return ends the method, cannot have code below return

21
Q

a method that calculates something

A

returns a calculated value (not void)

22
Q

break

A

breaks out of the switch or a loop

23
Q

input/output methods

A

format output for the user
error check user input

24
Q

methods

A

block code that when called, performs an action
allows for splitting of long code into smaller chunks

25
Q

&&

A

returns true if both are true