Hello world, variables and operators Flashcards

1
Q

what is the name given to a variable

A

the identifier

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

words that cannot be used as variable names

A

reserved keywords

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

byte

A

8 bit signed twos complement integer
default value 0
used to save space in large arrays

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

short

A

16 bit sign twos complement integer
min (-2^15)
max (2 ^16)
can also be used to save memory as is two times smaller than an int

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

int

A

32 bits
min value (-2^31)
max value(2^32)
default data type unless there is a concern about memory

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

long

A

64 bit twos complement integer
default value is 0

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

float

A

32 bit floating point default is 0.0f
mainly used to save memory in large arrays of floating point numbers

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

double

A

64 bit IEEE 754 floating point
generally default data type used for floating point number values

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

boolean

A

1 bit of information
default value is false

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

char

A

16 bit is a single 16 bit unicode character
min value is \u0000 or 0
max value is \uffff or 65,535
used to store any character

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

How are reference variables created

A

using defined constructors of classes

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

why are reference variables used

A

to access objects

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

Default value of a reference variable

A

null (as opposed to primitive data types where the default value is 0 which means you can store data with no value).

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

steps of using a variable

A

declaration - when the variable is declared
initialisation - when the variable is initially given a value
assignment - when a variable is given assignment at some point after being createed

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

what is a condition

A

an expression which can evaluate to true or false

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

example of a selection statement

A

a selection statement allows a program to make a decision based on a conditions value
If and switch statements

17
Q

equality operators

A

== and !=

18
Q

relational operators`

A

> and < and >= and <=

19
Q

Under the bonnet

A

java is platform independent - this means it will run on almost any operating system
portability - java must run similarly on any supported hardware/operating system platform

20
Q

java portability

A

bytecode - portability achieved by compiling java into an intermediate representation called java bytecode instead of directly to platform specific machine code
bytecode instructions are analogous to machine code, but are interpreted by a JVM (java virtual machine)

21
Q

compiling and running java

A

step 1 - developers write the source code which is saved with the file extension .java
step 2 - Javac is used to to turn (compile) the source code into byte code
step 3 - After javac has finished compiling the bytecode, it creates a new file with the extension .class
step 4 - one the class file has been created, it can be passed onto and run on the JVM

22
Q

compiler vs interpreter

A

compiler - translates entire source code into machine or intermediate code, then an executor generates the ouput
interpreter - a program which reads one statement at a time and translates it to the machine code or virtual machine code and executes it straight away.

23
Q

JVM platform independent

A

there is a jvm for each platform