Download Android App in your Android Device from Google Play Store
- Search for "Withoutbook Practice Exam Test" in Mobile/Tablet Play Store
Practice InterviewNew Search by Name or Email

Exams Attended

Make Homepage

Bookmark this page

Subscribe Email Address

Core Java Interview Questions and Answers

Ques 256. What kind of thread is the Garbage collector thread?

Ans. It is a daemon thread.

Is it helpful? Add Comment View Comments
Ques 257. Explain Garbage collection mechanism in Java?
Ans. Garbage collection is one of the most important features of Java. The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources can be reclaimed and reused. A Java object is subject to garbage collection when it becomes unreachable to the program in which it is used. Garbage collection is also called automatic memory management as JVM automatically removes the unused variables/objects (value is null) from the memory. Every class inherits finalize() method from java.lang.Object, the finalize() method is called by garbage collector when it determines no more references to the object exists. In Java, it is good idea to explicitly assign null into a variable when no more in use.
In Java on calling System.gc() and Runtime.gc(), JVM tries to recycle the unused objects, but there is no guarantee when all the objects will garbage collected. Garbage collection is an automatic process and can't be forced. There is no guarantee that Garbage collection will start immediately upon request of System.gc().
Is it helpful? Add Comment View Comments
Ques 258. What is difference between String and StringTokenizer?
Ans. A StringTokenizer is utility class used to break up string. Example:
StringTokenizer st = new StringTokenizer("Hello World");
while (st.hasMoreTokens()) {
Is it helpful? Add Comment View Comments
Ques 259. Can a method be static and synchronized?
Ans. A static method can be synchronized. If you do so, the JVM will obtain a lock on the java.lang. Class instance associated with the object. It is similar to saying:
synchronized(XYZ.class) { 
Is it helpful? Add Comment View Comments
Ques 260. What is phantom memory?
Ans. Phantom memory is false memory. Memory that does not exist in reality.
Is it helpful? Add Comment View Comments

Most helpful rated by users:

©2020 WithoutBook