What is JVM, JRE, JDK?
JVM is responsible for converting Byte code to the machine specific code
JRE is the implementation of JVM, it provides a platform to execute java programs. JRE
consists of JVM and java binaries and other classes to execute any program successfully
JDK Java Development Kit is the core component of Java Environment and provides all the
tools, executables and binaries required to compile, debug and execute a Java Program
JIT – Sometimes we heard this term and being it a part of JVM it confuses us. JIT is
part of JVM that optimizes byte code to machine specific language compilation by
compiling similar byte codes at the same time, hence reducing overall time taken for
the compilation of byte code to machine specific language.
What is the JVM memory structure in RAM?
What is class in Java?
Every class in java extends Object class
Main method in all types of java classes interface, abstract, enum and normal class.
Normal Class can be created with only public, abstract, final and default access modifiers.
String memory management?
-----
Arrays in java
How to iterate any Map in Java
What is thread-safe collections? ConcurrentHashMap and LinkedBlockingQueue
PriorityBlockingQueue
Collections is a class in java and Collection is an interface in Java.
Differences
Vectors are synchronized, ArrayLists are not.
Data Growth Methods
Use ArrayLists if there is no specific requirement to use Vectors.
Synchronization
If multiple threads access an ArrayList concurrently then we must externally synchronize
the block of code which modifies the list either structurally or simply modifies an element.
Structural modification means addition or deletion of element(s) from the list. Setting the
value of an existing element is not a structural modification.
Collections.synchronizedList is normally used at the time of creation of the list to avoid
any accidental unsynchronized access to the list.
Reference
Data growth
Internally, both the ArrayList and Vector hold onto their contents using an Array. When an
element is inserted into an ArrayList or a Vector, the object will need to expand its internal
array if it runs out of room. A Vector defaults to doubling the size of its array, while the
ArrayList increases its array size by 50 percent.
Siders:
MultiMap | Guava | Java
Introduction : A Multimap is a general way to associate keys with arbitrarily many values.
Guava’s Multimap framework makes it easy to handle a mapping from keys to multiple
values. There are two ways to think of a Multimap conceptually :
1) As a collection of mappings from single keys to single values.
a -> 1
a -> 2
a -> 4
b -> 3
c -> 5
2) As a mapping from unique keys to collections of values.
a -> [1, 2, 4]
b -> [3]
c -> [5]
4) Why Map interface does not extend Collection interface?
A good answer to this interview question is “because they are incompatible“. Collection has
a method add(Object o). Map can not have such method because it need key-value pair.
There are other reasons also such as Map supports keySet, valueSet etc. Collection classes
does not have such views.
Due to such big differences, Collection interface was not used in Map interface, and it was
build in separate hierarchy.
Tag : java thread
Java ExecutorService examples
By mkyong | December 5, 2018 | Viewed : 30,476 | +1,080 pv/w
Java Thread – Mutex and Semaphore example
By Datsabk | December 4, 2016 | Viewed : 96,834 | +827 pv/w
Junit - https://www.mkyong.com/tutorials/junit-tutorials/
XML parsers - https://www.mkyong.com/tutorials/java-xml-tutorials/