Interview Questions on Java
What is the purpose of the toolkit in the Abstract Window Toolkit
(AWT)? How does AWT work?
A: The AWT toolkit is an interface between the abstract window layer
and a specific windowing implementation.
What is layout manager ? How does it work?
A: A layout manager is an object that positions and resizes the components
in a Container according to some algorithm; for example, the FlowLayout
layout manager lays out components from left to right until it runs out
of room and then continues laying out components below that row.
Compare SWING components to standard AWT.
A: Swing is an extension of, and not a replacement for the AWT. There
is some overlap between AWT and Swing (for example a Swing JButton component
might be viewed as an improved functional replacement for an AWT Button
component.) One of the advantages of Swing components is that because the
components are not rendered on the screen by the operating system, the
look and feel of a component does not change as the application or applet
is executed on different platforms running under different operating systems.
Furthermore, it is possible to cause Swing components to mimic the look
and feel of a specific platform no matter what platform the program is
running on. This is known as pluggable look and feel. Swing components
support the JDK 1.1
Delegation Event Model. From an event handling viewpoint, Swing components
operate the same as AWT components (except that Swing provides a number
of new event types). Many Swing components don't have an AWT counterpart.
A number of new and exciting components are included in the Swing library
that don't exist in the AWT (tooltips, progress bars, trees, etc.)
What is Java Beans?
A: According to JavaSoft, "A Java Bean is a reusable software component
that can be manipulated visually in a builder tool."
What you know about Corba implementation in Java?
A: Java 1.2 promises full CORBA IDL support.
What do you know about networking support in Java?
A: Java supports "low-level" and "high-level" classes. "Low-level"
classes provide support for socket programming: Socket, DatagramSocket,
and ServerSocket classes. "High-level" classes provide "Web programming":
URL, URLEncoder, and URLConnection classes. Networking programming classes
ease the programming of network applications, but do not substitute your
knowledge of networking. Java networking like anything else in Java is
What is it object serialization?
A: Serialization is a way to convert objects (including complex data
structures such as lists and trees) into a stream of bytes.
How to make application thread-safe?
A: You should use the word synchronized to mark the critical section
of code. You may also use other methods of thread synchronization (see
wait(), notify(), notifyAll() etc.
What is it reflection (introspection) ? Why is reflection possible
in the Java language?
A: Reflection (introspection) is querying a class about its properties,
and operating on methods and fields by the name for a given object instance.
Reflection is possible in the Java language because of late binding.
Why are Java ARchive (JAR) files important?
A: JAR files bundle .class files and optimize applet downloads.
Describe what happens when an object is created in Java.
A: Several things happen in a particular order to ensure the object
is constructed properly:
1. Memory is allocated from heap to hold all instance variables and
implementation-specific data of the object and its superclasses. Implemenation-specific
data includes pointers to class and method data.
2. The instance variables of the objects are initialized to their default
3. The constructor for the most derived class is invoked. The first
thing a constructor does is call the consctructor for its superclasses.
This process continues until the constrcutor for java.lang.Object is called,
as java.lang.Object is the base class for all objects in java.
4. Before the body of the constructor is executed, all instance variable
initializers and initialization blocks are executed. Then the body of the
constructor is executed. Thus, the constructor for the base class completes
first and constructor for the most derived class completes last.
In Java, You can create a String object as below : String str = "abc";
& String str = new String("abc");
Why cant a button object be created as : Button bt = "abc" Why is
it compulsory to create a button object as: Button bt = new Button("abc");
Why this is not compulsory in String's case?
A: The main reason you cannot create a button by
Button bt1= "abc";
is because "abc" is a literal string (something slightly different than
a String object, by-the-way) and bt1 is a Button object. That simple. The
only object in Java that can be assigned a literal String is java.lang.String.
Important to not that you are NOT calling a java.lang.String constuctor
when you type String s = "abc";
String x = "abc";
String y = "abc"; refer to the same object. While
String x1 = new String("abc"); String x2 = new String("abc"); refer
to two different objects.
Do you have a Java Problem?
Ask It in The Java
Certification, Programming, JavaBean and Object Oriented Reference Books
Return to : Java
Programming Hints and Tips
All the site contents are Copyright © www.erpgreat.com
and the content authors. All rights reserved.
All product names are trademarks of their respective
The site www.erpgreat.com is not affiliated with or endorsed
by any company listed at this site.
Every effort is made to ensure the content integrity.
Information used on this site is at your own risk.
The content on this site may not be reproduced
or redistributed without the express written permission of
www.erpgreat.com or the content authors.