Q.1 What is garbage collection? What is the process that is responsible for doing that in java?
ANSWER:
Reclaiming the unused memory by the invalid objects. Garbage collector is responsible for this process
Q.2 What kind of thread is the Garbage collector thread?
ANSWER:
It is a daemon thread.
Q.3 What is a daemon thread?
ANSWER:
These are the threads which can run without user intervention. The JVM can exit when there are daemon thread by killing them abruptly.
Q.4 How will you invoke any external process in Java?
ANSWER:
Runtime.getRuntime().exec(….)
Q.5 What is the finalize method do?
ANSWER:
Before the invalid objects get garbage collected, the JVM give the user a chance to clean up some resources before it got garbage collected.
Q.6 What is mutable object and immutable object?
ANSWER:
If a object value is changeable then we can call it as Mutable object. (Ex., StringBuffer, …) If you are not allowed to change the value of an object, it is immutable object. (Ex., String, Integer, Float, …)
Q.7 What is the basic difference between string and stringbuffer object?
ANSWER:
String is an immutable object. StringBuffer is a mutable object.
Q.8 What is the purpose of Void class?
ANSWER:
The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the primitive Java type void.
Q.9 What is reflection?
ANSWER:
Reflection allows programmatic access to information about the fields, methods and constructors of loaded classes, and the use reflected fields, methods, and constructors to operate on their underlying counterparts on objects, within security restrictions.
Q.10 What is a package?
ANSWER:
To group set of classes into a single unit is known as packaging. Packages provides wide namespace ability.
Q.11 What are the approaches that you will follow for making a program very efficient?
ANSWER:
By avoiding too much of static methods avoiding the excessive and unnecessary use of synchronized methods Selection of related classes based on the application (meaning synchronized classes for multiuser and non-synchronized classes for single user) Usage of appropriate design patterns Using cache methodologies for remote invocations Avoiding creation of variables within a loop and lot more.
Q.12 What is a DatabaseMetaData?
ANSWER:
Comprehensive information about the database as a whole.
Q.13 What is Locale?
ANSWER:
A Locale object represents a specific geographical, political, or cultural region
Q.14 How will you load a specific locale?
ANSWER:
Using ResourceBundle.getBundle(…);
Q.15 What is JIT and its use?
ANSWER:
Really, just a very fast compiler… In this incarnation, pretty much a one-pass compiler — no offline computations. So you can’t look at the whole method, rank the expressions according to which ones are re-used the most, and then generate code. In theory terms, it’s an on-line problem.
Q.16 What is the final keyword denotes?
ANSWER:
final keyword denotes that it is the final implementation for that method or variable or class. You can’t override that method/variable/class any more.