21. What is classloader?
The
classloader is a subsystem of JVM which is used to load classes and interfaces.
Types :-
Bootstrap classloader
Extension
classloader
System classloader
Plugin classloader etc.
22. How do you find memory usage
from Java program and How much percent of the heap is used?
java.lang.Runtime
class has all memory related methods to get free memory,total memory and
maximum heap memory in Java.From that you can find out how many % of heap is
used and how much is remaining.
Following
methods can be used:
Runtime.freeMemory() -returns
amount of free memory (in bytes)
Runtime.totalMemory()- returns total memory in (bytes)
Runtime.maxMemory() -returns
maximum memory (in bytes)
23. What's
the difference between "a == b" and ‘a.equals(b)’?
The ‘a == b’ is used for object reference
matching. If both a and b are an object then ‘a==b’ only return true if both
are pointing to the same object in the heap memory.
The ‘a.equals(b)’ is used for logical mapping and
to provide logical equality, an object has to override this method. It actually
does object content matching.
24. Can you guarantee
the garbage collection process?
No, you cannot , but you can make a request using System.gc() or Runtime.gc() method.
No, you cannot , but you can make a request using System.gc() or Runtime.gc() method.
25. What is the
difference between Serial and Parallel Garbage Collector?
A serial collector is a default copying
collector which uses only one GC thread for garbage collection while a parallel
collector uses multiple GC threads for garbage collection.
No comments:
Post a Comment