java Flashcards
JVM vs JRE vs JDK
Spec vs runtime vs runtime + dev tools
Is java 100% oriented?
No - primitive types
Wrapper classes
Wrap primitives to add some API / use in collection
Constructor
A block of code to initialise an object. Same name as class, no return type
Singleton
Only one instance in JVM. Private constructor
ArrayList vs Vector
Fast, non-synchronised vs Slow and synchronised
equals() vs ==
Equality of objects from business perspective vs memory address.
Stack
LIFO, stack memory can be used by other threads, contains local, primitive and reference variables to objects in heap space, exists until the end of execution of the thread. -Xss, StackOverflow
Heap
Memory lives until the end of app: objects. classes -Xms and -Xmx OutOfMemoryError
What is a package in Java? Why?
A collection of related classes and interfaces to modularise code and avoid name clashes.
Why pointers are not used in Java?
JVM is responsible for implicit memory allocation.
What is JIT compiler in Java?
Compiler decides which parts of the code should be optimised.
What are access modifiers in Java?
Keywords to restrict access to class method, field: public, protected, default, private.
OOP
Programs are organised around objects rather than logic and functions.
FP
Programs are organised around functions, avoiding shared state, mutable data, and side-effects (changing something somewhere - changing variable’s value, writing data to disk, enable a button in UI).
PP
Procedures, also known as routines, subroutines, or functions, simply contain a series of computational steps to be carried out.
What are the main concepts of OOPs?
Inheritance, Encapsulation, Abstraction, Polymorphism.