1.What is the finalize method do?
– Before the invalid objects get garbage collected, the JVM give the user a chance to clean up some resources before it got garbage collected.
2. What is mutable object and immutable object?
– 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, …)
3. What is the basic difference between string and stringbuffer object?
– String is an immutable object. StringBuffer is a mutable object.
4. What is the purpose of Void class?
– The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the primitive Java type void.
5.What is reflection?
– 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.
6. What is the base class for Error and Exception?
– Throwable
7. What is a package?
– To group set of classes into a single unit is known as packaging. Packages provides wide namespace ability.
8. What is JIT and its use?
– 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.
9. Is JVM a compiler or an interpreter?
– Interpreter
10. What is the purpose of assert keyword?
– In order to validate certain expressions. It effectively replaces the if block and automatically throws the AssertionError on failure. This keyword should be used for the critical arguments. Meaning, without that the method does nothing.
13. How will you get the platform dependent values like line separator, path separator, etc., ?
– Using Sytem.getProperty(…) (line.separator, path.separator, …)
14. What is garbage collection? What is the process that is responsible for doing that in java?
– Reclaiming the unused memory by the invalid objects. Garbage collector is responsible for this process.
15. What kind of thread is the Garbage collector thread?
– It is a daemon thread. What is a daemon thread? – These are the threads which can run without user intervention. The JVM can exit when there are daemon thread by killing them abruptly.
16. How will you invoke any external process in Java?
– Runtime.getRuntime().exec(….)
17. What do you understand by numeric promotion?
The Numeric promotion is the conversion of a smaller numeric type to a larger numeric type, so that integer and floating-point operations may take place. In the numerical promotion process the byte, char, and short values are converted to int values. The int values are also converted to long values, if necessary. The long and float values are converted to double values, as required
18. What do you understand by casting in java language?
The process of converting one datatype to another in Java language is called Casting.
19. What are the types of casting?
There are two types of casting in Java, these are Implicit casting and explicit casting.
20. What is Implicit casting?
Implicit casting is the process of simply assigning one entity to another without any transformation guidance to the compiler. This type of casting is not permitted in all kinds of transformations and may not workout for all application scenarios.
eg.
int i = 20;
long h = i; //Implicit casting
21. What is explicit casting?
Explicit casting in the process in which the complier are specifically informed to about transforming the object.
eg.
long ln = 700.20;
t = (int) ln; //Explicit casting
22. What do you understand by downcasting?
The process of Downcasting refers to the casting from a general to a more specific type, i.e. casting down the hierarchy
23. What do you understand by downcasting?
The process of Downcasting refers to the casting from a general to a more specific type, i.e. casting down the hierarchy
24. What do you understand by final value?
FINAL for a variable: value is constant. FINAL for a method: cannot be overridden. FINAL for a class: cannot be derived
25. What is the final keyword denotes?
– 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.
26. What is the major difference between LinkedList and ArrayList?
– LinkedList are meant for sequential accessing. ArrayList are meant for random accessing.
27. What is nested class?
– If all the methods of a inner class is static then it is a nested class.
28. What is inner class?
– If the methods of the inner class can only be accessed via the instance of the inner class, then it is called inner class.
29. What are the methods in Object?
– clone, equals, wait, finalize, getClass, hashCode, notify, notifyAll, toString
30. What is singleton?
– It is one of the design pattern. This falls in the creational pattern of the design pattern. There will be only one instance for that entire JVM. You can achieve this by having the private constructor in the class. For eg., public class Singleton ()
{
private static final Singleton s = new Singleton();
private Singleton()
{
}
public static Singleton getInstance() { return s; } // all non static methods … }
31. What is Class.forName() does and how it is useful?
– It loads the class into the ClassLoader. It returns the Class. Using that you can get the instance ( “class-instance”.newInstance() ).
No comments:
Post a Comment