Java / OO Flashcards
Name the access modifiers
public, private, protected
What’s another name for a mutator method?
setter
What’s another name for an accessor method?
getter
Whats happens in the first stage of Java compilation?
Compiled into bytecode. Low-level but not hardware-specific. Catches syntax errors.
What happens when you run a Java program?
Bytecode compiled further by a JVM (Java Virtual Machine). Executed.
What’s the name for the Java style of compilation?
‘Just in time’ compilation.
Is the Java style of compilation faster or slower than the normal type and why?
Can be faster because can be compiled in smaller chunks depending on which bit of the code you are running, and therefore optimised.
What’s the file extension on a source code file?
.java
What’s the file extension on a compiled Java file?
.class
What’s the command to compile a java file or files?
javac *.java
How do you run a Java program with a main method?
java ClassName
How do you run a Java program with a package name and a main method?
java my.package.ClassName
How do you control what “a string” + myObject outputs?
Implement the toString() method on myObject
Explain what it means in practice that strings are immutable
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.
What’s a wrapper class (types)?
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