Week 1-6 Flashcards
What is machine code?
Low level hexadecimal instructions
What is assembly language?
Low-level programming language with symbols for instructions.
What is high level programming language?
Easier to understand. Translated to machine code by compiler.
Explain life-cycle of a C-file?
Starts as basic text file.
Compiler takes C file and produces an executable.
When we execute loaded into memory.
CPU executes.
What are the problems with machine code?
Computer systems are different.
OS provide different libraries
Different CPUs cannot execute the same program and have different instructions
Programs must be compiled again for the different CPU types.
Why do we download different versions of software for each OS?
Cause each OS has different libraries and code must be compiled differently for each.
What is the advantage of JVM?
Write code once, run on any OS?
What is a java program compiled to?
bytecode
Why do we not need dynamic memory allocation?
JVM garbage collector frees memory automatically.
What does IDE stand for?
Integrated Development Environment
When we perform calculations with different typing in java, what type does the result take?
The longest type.
What is autoboxing and unboxing?
A: Primitive type converted to wrapper object. E.g. Integer i = 4;
U: Wrapper object converted to primitive type. int i = intObj;
Syntax for array declaration in java.
int[] numbers = new int[size];
Syntax to get length of array test.
test.length
Syntax for ArrayList.
ArrayList<TYPE> array = new ArrayList<TYPE>();</TYPE></TYPE>
What is OOP?
Is based on the concept of objects which can encapsulate both data and behavior. Designed to model real-world entities and their interactions.
What is cohesion?
Programs are broke up into classes. Classes contain related functionalities. The more related the higher the cohesion.
Difference between object and class.
Class is an idea. E.g. idea of a ‘chair’
Object is an instance of idea, real thing.
What is a default constructor?
Constructor with no parameters, that initializes instance variables to their default values.
T or F. We can have more than one constructor.
True.
What does a constructor implicitly return?
A reference to where the object is in memory.
How does copying a primitive differ from copying an object in java?
If I copy a primitive, a whole new copy is made in memory, so changing the copy won’t affect original.
If I copy an object, a reference is all that is copied, so if I edit the copy, the original will also be affected.
Syntax for default constructor.
public Name() {
}
Main syntax.
public static void main(String[] args) {
}