Difference between “==” and equals()
”==” is a binary operator, used to compare primitives and sometimes objects, but with objects compares the memory reference.
equals() is a method, used for checking equality of two objects defined by business logic
Difference between String vs StringBuilder vs StringBuffer
String Class is inmutable
StringBuilder is mutable but not thread-safe
StringBuffer is mutable and thread-safe
Access Level «protected»
Same class, same package, sub class in another package
Access Level «defalut»
Same class, same package
Access Level «private»
Same class
Access Level «public»
Anyplace
static Keyword
static Methods
Difference between Abstract class and interface
Abstract class usually contains at least one abstract method, cannot be instantied Interface contains only abstract methods, cannot be instantied
Features of list interface
- Is an ordered collection of elements Behaviors - Adding, getting, removing and overwriting elements at a specific index - Getting the size of the list - Allows duplicate elements - Ordered
Features of set interface
Features of map interface
Features of deque interface
Features of comparable interface
Features of comparator interface
finally block
Always runs regardless of wheter or not an error ocurred during the execution of the try block
TreeMap
A map where the keys are automatically sorted
HashTable
A classic associative array implementation with keys and values, is synchronized
HashMap
An implementation just like HashTable except that it accepts null keys and values. Also, it is not synchronized
Extends and implements
In a normal class you can implement multiple interfaces, but not extends multiple classes
Stack vs Heap memory
Stack is a dedicated space to save information and Heap is dynamically space that grows as part of the program
Garbage Collector
Free up memory space is not being used anymore, ensure memory is using efficiently