Top Listed Java Interview Questions Part – 3
117) What is Garbage Collection?
Garbage collection is a process of reclaiming the runtime unused objects.It is performed for memory management.
118) What is gc()?
gc() is a daemon thread.gc() method is defined in System class that is used to send request to JVM to perform garbage collection.
119) What is the purpose of finalize() method?
finalize() method is invoked just before the object is garbage collected.It is used to perform cleanup processing.
120) Can an unrefrenced objects be refrenced again?
Yes.
121)What kind of thread is the Garbage collector thread?
Daemon thread.
122)What is difference between final, finally and finalize?
final: final is a keyword, final can be variable, method or class.You, can’t change the value of final variable, can’t override final method, can’t inherit final class.
finally: finally block is used in exception handling. finally block is always executed.
finalize():finalize() method is used in garbage collection.finalize() method is invoked just before the object is garbage collected.The finalize() method can be used to perform any cleanup processing.
123)What is the purpose of the Runtime class?
The purpose of the Runtime class is to provide access to the Java runtime system.
124)How will you invoke any external process in Java?
By Runtime.getRuntime().exec(?) method.
125)What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?
The Reader/Writer class hierarchy is character-oriented, and the InputStream/OutputStream class hierarchy is byte-oriented.
126)What an I/O filter?
An I/O filter is an object that reads from one stream and writes to another, usually altering the data in some way as it is passed from one stream to another.
127) What is serialization?
Serialization is a process of writing the state of an object into a byte stream.It is mainly used to travel object’s state on the network.
128) What is Deserialization?
Deserialization is the process of reconstructing the object from the serialized state.It is the reverse operation of serialization.
129) What is transient keyword?
If you define any data member as transient,it will not be serialized.more details…
130)What is Externalizable?
Externalizable interface is used to write the state of an object into a byte stream in compressed format.It is not a marker interface.
131)What is the difference between Serializalble and Externalizable interface?
Serializable is a marker interface but Externalizable is not a marker interface.When you use Serializable interface, your class is serialized automatically by default. But you can override writeObject() and readObject() two methods to control more complex object serailization process. When you use Externalizable interface, you have a complete control over your class’s serialization process.
132)How do I convert a numeric IP address like 192.18.97.39 into a hostname like java.sun.com?
By InetAddress.getByName(“192.18.97.39”).getHostName() where 192.18.97.39 is the IP address.
133) What is reflection?
Reflection is the process of examining or modifying the runtime behaviour of a class at runtime.It is used in:
IDE (Integreted Development Environment) e.g. Eclipse, MyEclipse, NetBeans.
Debugger
Test Tools etc.
134) Can you access the private method from outside the class?
Yes, by changing the runtime behaviour of a class if the class is not secured.
148)What are wrapper classes?
Wrapper classes are classes that allow primitive types to be accessed as objects.
149)What is a native method?
A native method is a method that is implemented in a language other than Java.
150)What is the purpose of the System class?
The purpose of the System class is to provide access to system resources.
151)What comes to mind when someone mentions a shallow copy in Java?
Object cloning.
152)What is singleton class?
Singleton class means that any given time only one instance of the class is present, in one JVM.
153)Which containers use a border layout as their default layout?
The Window, Frame and Dialog classes use a border layout as their default layout.
154)Which containers use a FlowLayout as their default layout?
The Panel and Applet classes use the FlowLayout as their default layout.
155)What are peerless components?
The peerless components are called light weight components.
156)is the difference between a Scrollbar and a ScrollPane?
A Scrollbar is a Component, but not a Container. A ScrollPane is a Container. A ScrollPane handles its own events and performs its own scrolling.
157)What is a lightweight component?
Lightweight components are the one which doesn?t go with the native call to obtain the graphical units. They share their parent component graphical units to render them. For example, Swing components.
158)What is a heavyweight component?
For every paint call, there will be a native call to get the graphical units.For Example, AWT.
159)What is an applet?
An applet is a small java program that runs inside the browser and generates dynamic contents.
160)Can you write a Java class that could be used both as an applet as well as an application?
Yes. Add a main() method to the applet.
161)What is Locale?
A Locale object represents a specific geographical, political, or cultural region.
162)How will you load a specific locale?
By ResourceBundle.getBundle(?) method.
163)What is a JavaBean?
are reusable software components written in the Java programming language, designed to be manipulated visually by a software development environment, like JBuilder or VisualAge for Java.
164)Can RMI and Corba based applications interact?
Yes they can. RMI is available with IIOP as the transport protocol instead of JRMP.