Oracle Java Interview Questions & Answers Set-8

«« Previous
Next »»

141) What comes to mind when someone mentions a shallow copy in Java?
Ans: Object cloning.


142) What is singleton class?
Ans: Singleton class means that any given time only one instance of the class is present, in one JVM.


AWT and SWING Interview Questions



143) Which containers use a border layout as their default layout?
Ans: The Window, Frame and Dialog classes use a border layout as their default layout.


144) Which containers use a FlowLayout as their default layout?
Ans: The Panel and Applet classes use the FlowLayout as their default layout.


145) What are peerless components?
Ans: The peerless components are called light weight components.


146) is the difference between a Scrollbar and a ScrollPane?
Ans: 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.


147) What is a lightweight component?
Ans: 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.


148) What is a heavyweight component?
Ans: For every paint call, there will be a native call to get the graphical units.For Example, AWT.


149) What is an applet?
Ans: An applet is a small java program that runs inside the browser and generates dynamic contents.


150) Can you write a Java class that could be used both as an applet as well as an application?
Ans: Yes. Add a main() method to the applet.


Internationalization Interview Questions



151) What is Locale?
Ans: A Locale object represents a specific geographical, political, or cultural region.


152) How will you load a specific locale?
Ans: By ResourceBundle.getBundle(?) method.


Java Bean Interview Questions



153)What is a JavaBean?
Ans: 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.


RMI Interview Questions



154) Can RMI and Corba based applications interact?
Ans: Yes they can. RMI is available with IIOP as the transport protocol instead of JRMP.


Java Multithreading Interview Questions



155) What is multithreading?
Ans: Multithreading is a process of executing multiple threads simultaneously. Its main advantage is:

  • Threads share the same address space.
  • Thread is lightweight.
  • Cost of communication between process is low.

156) What is thread?
Ans: A thread is a lightweight subprocess.It is a separate path of execution.It is called separate path of execution because each thread runs in a separate stack frame.


157) What is the difference between preemptive scheduling and time slicing?
Ans: Under preemptive scheduling, the highest priority task executes until it enters the waiting or dead states or a higher priority task comes into existence. Under time slicing, a task executes for a predefined slice of time and then reenters the pool of ready tasks. The scheduler then determines which task should execute next, based on priority and other factors.


158) What does join() method?
Ans: The join() method waits for a thread to die. In other words, it causes the currently running threads to stop executing until the thread it joins with completes its task.


159) What is difference between wait() and sleep() method?
Ans: 

wait()
sleep()
1) The wait() method is defined in Object class. The sleep() method is defined in Thread class.
2) wait() method releases the lock. The sleep() method doesn't releases the lock.


160) Is it possible to start a thread twice?
Ans: No, there is no possibility to start a thread twice. If we does, it throws an exception.

«« Previous
Next »»