Java / OO Flashcards

1
Q

Name the access modifiers

A

public, private, protected

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

What’s another name for a mutator method?

A

setter

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

What’s another name for an accessor method?

A

getter

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

Whats happens in the first stage of Java compilation?

A

Compiled into bytecode. Low-level but not hardware-specific. Catches syntax errors.

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

What happens when you run a Java program?

A

Bytecode compiled further by a JVM (Java Virtual Machine). Executed.

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

What’s the name for the Java style of compilation?

A

‘Just in time’ compilation.

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

Is the Java style of compilation faster or slower than the normal type and why?

A

Can be faster because can be compiled in smaller chunks depending on which bit of the code you are running, and therefore optimised.

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

What’s the file extension on a source code file?

A

.java

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

What’s the file extension on a compiled Java file?

A

.class

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

What’s the command to compile a java file or files?

A

javac *.java

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

How do you run a Java program with a main method?

A

java ClassName

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

How do you run a Java program with a package name and a main method?

A

java my.package.ClassName

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

How do you control what “a string” + myObject outputs?

A

Implement the toString() method on myObject

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

Explain what it means in practice that strings are immutable

A

Methods that appear to modify a string actually create and return a new string - so you have to reassign the result to a new variable.

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

What’s a wrapper class (types)?

A

e.g. Integer, Character - provides useful methods to perform on primitives, and is an ‘object’, which is useful e.g. for using as the generic in ArrayList

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

What’s a wrapper class (types)?

A

e.g. Integer, Character - provides useful methods to perform on primitives, and is an ‘object’, which is useful e.g. for using as the generic in ArrayList.

17
Q

List out the types of integer and their sizes

A

byte; int; short; long

8-bit; 16-bit; 32-bit; 64-bit

18
Q

List out the types of floating point number and their sizes

A

float; double

32-bit; 64-bit

19
Q

What is a char stored as?

A

16-bit unicode character

20
Q

Explain checked vs unchecked exceptions

A

checked at compile time

have to be handled or declare that they’re thrown

21
Q

guarding

A

if clause

22
Q

defensive programming

A

against unexpected exceptions from outside

23
Q

how to respond to an error

A

throw exception, print message, return false

24
Q

sources of input to a program

A

file, network, command line, database

25
Q

streams

A

System.in, System.out, System.err

26
Q

Type of System.in

A

PrintStream

27
Q

Classes for handling streams

A

BufferedReader, BufferedWriter, Scanner

28
Q

Non-blocking IO

A

e.g. async code

29
Q

Polymorphism

A

calling a method, deciding at runtime which object to call it on