Exam #1 Flashcards

Lessons 2-5 (20 cards)

1
Q

What is the difference between the following two:
(double) 5 / 2
(double) (5 / 2)

A

Only the first one will result in a double.

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

What is the difference between the following two:
(double) 3.5
Math.round(3.5)

A

The first one will just drop the decimal.
The second one will actually round upwards.

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

How would I read this?
false && true || false

A

&& has higher priority than ||.
False

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

How would I read this?
true || false

A

true

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

How would I read this?
false && false

A

false

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

What is De Morgan’s laws?

A

!(A && B) ≡ (!A) || (!B)
!(A || B) ≡ (!A) && (!B)

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

What is the fourth letter?
She ate that.

A

a space

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

What is a compiler?

A

Translates an entire code into binary in many steps

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

What is an interpreter?

A

Translates code one step or line at a time.

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

What type of language is Java?

A

A hybrid language (compiles and then interprets)

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

What is the variable?
What is the literal?
What is the declaration statement?
What is the assignment statement?
int a;
a = 17;

A

a
17
int = a;
a = 17;

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

What must variables start with?

A

letter
$
underscore

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

Compile Time error vs. Runtime Error

A
  • Will not compile correctly
  • Something wrong in syntax
    vs.
  • Your code will not end
  • Something is wrong while running it
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Primitive vs Reference type

A

Primitive stores the actual value for a variable
Reference refers to the address of a primitive

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

What is the difference?
5 / 0
5.0 / 0

A

Error
Infinity

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

When does a number truncate?

A

When a double –> int it loses its decimal places

17
Q

What is concatenation?

A

Adding Strings together

18
Q

Can int be converted to double?
Can double be converted to int?

19
Q

How do you convert a double to int?

A

(int) double
(int) 5.6 –> 5

20
Q

How do you do an enhanced for loop?

A

// Random Array here

for (class name : array name) {
function that affects each object
}