Finals Notes I Flashcards

(18 cards)

1
Q

What is a compiler language? Name an example.

A
  • Input is a whole program
  • Code turns into several binary code steps
  • C++
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is an interpreter? Name an example.

A
  • Reads program instruction by instruction
  • Does not make a binary executable file
  • Example: Python
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What type of language is Java?

A
  • Hybrid of both compiler and interpreter.
  • Compiles into byte code.
  • Byte code is read by a JVM.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What would give this error?
Main method not public.

A

Forgotten the word “public”

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

Why would an error occur here?
public static main(String[] args)

A

Forgetting the word “void”

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

What is a compile-time error? Name some examples.

A
  • Detected by the JVM before the program runs
  • Examples: Syntax errors like missing symbols or type mismatches
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a runtime error? Can you name some examples.

A
  • Occurs after a program compiles
  • Happens while a program is being executed
  • Examples: dividing by zero, null references, invalid indexes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How can you name a variable?

A
  • Starting with a letter, $, or _.
  • Generally in lowerCamelCase
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

int a, b;
a = 1234;
b = 99;
int c = a + b;

What are the variables, literals, declaration / assignment / combined statements?

A

a and b
1234 and 99
int a, b
a = 1234 and b = 99
int c = a + b

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

What does the word “final” do?

A

Prevents a variable from being altered.

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

What is a trace?

A

A table of variable values after each statement in a code.

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

What is the difference in declaring a char versus a String?

A

char uses ‘’ while String uses “”

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

What is a primitive type? Name an example.

A
  • Basic type
  • Stories primitive values
  • Does not have associated methods
  • Example: char
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a reference type? Name an example.

A
  • Instantiable classes that use primitive types
  • Reference variables store the address
  • Have associated methods
  • Example: String
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do primitive and reference types store data?

A

Primitive types store actual values while reference types store the reference or “arrow” to an address

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

Can doubles be assigned integer values?

A

Yes. The integer is automatically converted to a double.

17
Q

What is the difference between 5/2.0 and 5.0/2?

A

They are treated the same. Only one of the numbers has to be a double for the answer to be a double.

18
Q

What is the difference between 5/0 and 5.0/0?

A

ArithmeticException vs. Infinity