java Flashcards
(43 cards)
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.
Inheritance
A process where one class acquires the properties of another.
Encapsulation
Data can be accessed only with accessors.
Abstraction
Only the essential details are displayed to the user / also identifying only the required characteristics of an object ignoring the irrelevant details.
Local vs instance variable
Used / scope inside a code block (controller, method) vs belongs to an object, declared on a class level.
final
Variable (value can’t be changed once assigned), method (can’t be overridden), class (can’t be extended)
break vs continue
Continue loop only, jumps to the next iteration
this() vs super()
Instance of a current vs parent class.