Variables Flashcards
why do we need variables
to use and re use them in code later
generic format for variable
type name = expression
what does type mean
the type of data that is being stored
exmaples of types
integers, doubles, characters, bytes, shorts, longs, floats, booleans
why do we need a name
to refer to the later
what do we mean by an expression
assigning the variable a value
rules for names of variables
- lowerCamelCase
- numbers cannot be first
- meaningful
what does lower camel case mean
first word is lower case first letter and every word after that begins with a capital letter
two booleans
true and false
why might they have used byte years ago rather than the default of int that we use nowadays
for maximum space storage
max of char? why is this
65535 (all characters of all languages ww)
what does it mean when we say its lossy
we cannot possibly accurately represent all the digits after a decimal eg PI
example of a lossy precision
PI
When are variables in scope
from the point they are defined until the body in which they are defined is ended (curley brackets ended)
what does the error “cannot be resolved” mean
that the variable is not in scope