Variables Flashcards

1
Q

why do we need variables

A

to use and re use them in code later

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

generic format for variable

A

type name = expression

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

what does type mean

A

the type of data that is being stored

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

exmaples of types

A

integers, doubles, characters, bytes, shorts, longs, floats, booleans

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

why do we need a name

A

to refer to the later

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

what do we mean by an expression

A

assigning the variable a value

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

rules for names of variables

A
  1. lowerCamelCase
  2. numbers cannot be first
  3. meaningful
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what does lower camel case mean

A

first word is lower case first letter and every word after that begins with a capital letter

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

two booleans

A

true and false

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

why might they have used byte years ago rather than the default of int that we use nowadays

A

for maximum space storage

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

max of char? why is this

A

65535 (all characters of all languages ww)

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

what does it mean when we say its lossy

A

we cannot possibly accurately represent all the digits after a decimal eg PI

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

example of a lossy precision

A

PI

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

When are variables in scope

A

from the point they are defined until the body in which they are defined is ended (curley brackets ended)

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

what does the error “cannot be resolved” mean

A

that the variable is not in scope

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

to use a statement from a for loop outside of a for loop we must

A

define it beforehand

17
Q

can you redefine a variable in scope

A

no

18
Q

when are variables defined in the initializtion of a for loop destroyed

A

when the for loop is completed

19
Q

when are variables that are defined in the body of a for loop destroyed

A

after each iteration of the loop