Basic Flashcards
Explain the JVM
An abstract machine. Provides a runtime environment where java bytecode is executed
Explain the JRE
An environment where java bytecode can be executed
Explain “main” in public static void main
Name of the method searched by the JVM as the starting point. Args are the parameters passed
What are wrapper classes?
Wrapper classes wrap a class or structure and implements other useful methods. They encapsulate the data or primitive type
What are constructors in Java?
A block of code to initialize an object. There are 2 types default constructors don’t need to be explicitly written. Parameterized constructors need parameters to init the object
What is a singleton class
A singleton is a design pattern first of all. It is a class that only can have one instance at a time in one JVM. You can achieve this by making a constructor private
ArrayList vs Vector
ArrayList : is not synchronized. Faster. Grows by 50% of its size. Can only use iterator to traverse
Vector: Is synchronized and slow. Defaults to doubling the size of array.
Heap Memory
Heap memory is used by all parts of the application. Objects on the heap are globally accessible. Memory lives from start to end of application. All objects are placed on the heap
Stack Memory
Memory is used by one thread of execution. This memory can’t be accessed from other threads. Exists for duration of the executed thread. Memory only contains local primitive and references in heap space
What is the synchronized
Capability to control the access of multiple threads to shared resources.
Interface vs Abstract
If you have common code use an abstract class. If the implementation code aren’t the same
What is JIT compiler
This compiler is used to improve performance. JIT will compile part of the the byte code that have similar functionality at the same time