Anda di halaman 1dari 24

Q--What are wrapper classes?

A--The wrapper classes are under the java.lang and java.util directories. The wr
apper classes are: Double, Integer, Character, and Boolean.
Wrapper classes are final and hence cannot be sub classed..
The methods of the wrapper classes are all static so you can use them without cr
eating an instance of the matching wrapper class. Remember that the wrapper clas
ses are just that classes, they are not primitives and instances of the wrappers
can only be manipulated in the same way as any class. 1) The Integer class has
a String and an int constructor - 2) The Integer has a floatValue() method - 3)
The wrapper classes are contained in the java.lang.Math package - 4) The Double
class has constructors for type double and float.

Q--What is Singleton class?

A--Singleton class is a class whose only one object can be created at a time. -
To achieve this one method is that we make its constructor private and provide a
static method that returns its instance.
When a Singleton class is garbage - collected and then reloaded, a new Singleton
instance is created.

Q--What is anonymous class?

A--An anonymous class is a local class that has no name..


An anonymous class is never abstract. An anonymous class is always an inner clas
s; it is never static. An anonymous class is always implicitly final

Q--What is typecasting?

A--Typecasting is the automatic conversion from one data type to another data ty
pe.

Q--What is JVM?
A--An abstract computing machine, or virtual machine , JVM is a platform - indep
endent execution environment that converts Java bytecode into machine language a
nd executes it.
Q--What is the middleware. What is the functionality of Webserver?
A--Middleware:
Software that facilitates interoperability by mediating between an application p
rogram and a network, thus masking differences or incompatibilities in network t
ransport protocols, hardware architecture, operating systems, database systems,
remote procedure calls, etc. An example is the Object Request Broker (ORB), soft
ware that manages communication between objects.
Webserver Functionality:
A-- Web server handles the HTTP protocol. When the Web server receives an HTTP r
equest, it responds with an HTTP response, such as sending back an HTML page. To
process a request, a Web server may respond with a static HTML page or image, s
end a redirect, or delegate the dynamic response generation to some other progra
m such as CGI scripts, JSPs (JavaServer Pages), servlets, ASPs (Active Server Pa
ges), server-side JavaScripts, or some other server-side technology. Whatever th
eir purpose, such server-side programs generate a response, most often in HTML,
for viewing in a Web browser.

Q--Why Java is not fully object oriented?


A--Java is not a fully object oriented language because it does not support mult
iple inheritance directly.But it does so by using theconcept of interfaces.
A language is said to be fully object oriented if it supports classes,objects,in
heritance and polymorphism.For example C++ supports full fledged feature of inhe
ritance and all the types of inheritances(single,multilevel,multiple,hierarchica
l and multipath inheritances), and if we take the polymorphism C++ supports stat
ic binding and operator overloading which come under static polymorphism where a
s Java does not support operator overloading.
We cannot say Java as an Object based language because it supports Inheritance a
nd polymorphism to some extent. Where as in object based languages there are cla
sses and objects but no inheritance and polymorphism.

Q--Explain 2 tier and 3 -tier Architecture?


A--JDBC supports both
two tier: ( client server configuration)
three- tier model: commands are sent to a middle tier , which then send SQL state
ments to the database. The database processes the SQL statements and sends the r
esult back to the middle tier( provides performance advantage)

Q--Can the abstract class be final?


A-- No, Combination of modifiers final and abstract is illegal in java.

Q--Diff between ArrayList and Vector?


A--Vector class is Synchronized and ArrayList class is not Synchornized.
Q--Which class is extended by all other classes?
A--The Object class is extended by all other classes.
Q--Which containers may have a MenuBar?
A--Frame.
Q--How are commas used in the intialization and iteration parts of a for stateme
nt?
A--Commas are used to separate multiple statements within the initialization and
iteration parts of a for statement.
================================================================================
=======================

Q.Name four Container classes?


A- Window, Frame, Dialog, FileDialog, Panel, Applet, or ScrollPane

q-What is the immediate superclass of the Dialog class?


a- Answer Window

What is synchronization and why is it important?


With respect to multi threading, synchronization is the capability to control th
e access of multiple threads toshared resources. Without synchronization, it is
possible for one
thread to modify a shared object while another thread is in the process of using
or updating that object's value. This often leads to significant errors.

What are the problems faced by Java programmers who don't use layout managers?
Without layout managers, Java programmers are faced with determining how their G
UI will be displayed across multiple windowing systems and finding a common sizi
ng and positioning that will work within the constraints imposed by each windowi
ng system

What are wrapped classes?


Wrapped classes are classes that allow primitive types to be accessed as objects
.

q -How many different types of JDBC drivers are present? Discuss them.
ans ---
Type 1: JDBC-ODBC Bridge plus ODBC Driver: The first type of JDBC driver is the
JDBC-ODBC Bridge. It is a driver that provides JDBC access to databases through
ODBC drivers. The ODBC driver must be configured on the client for the bridge to
work. This driver type is commonly used for prototyping or when there is no JDB
C driver
available for a particular DBMS.
Type 2: Native-API partly-Java Driver: The Native to API driver converts JDBC co
mmands to DBMS-specific native calls. This is much like the restriction of Type
1 drivers.
The client must have some binary code loaded on its machine. These drivers do ha
ve an advantage over Type 1 drivers because they interface directly with the dat
abase.
Type 3: JDBC-Net Pure Java Driver: The JDBC-Net drivers are a three-tier solutio
n. This type of driver translates JDBC calls into a databaseindependent network
protocol
that is sent to a middleware server. This server then translates this DBMSindepe
ndent protocol into a DBMS-specific protocol, which is sent to a particular data
base. The
results are then routed back through the middleware server and sent back to the
client. This type of solution makes it possible to implement a pure Java client.
It also makes
it possible to swap databases without affecting the client.
Type 4: Native-Protocol Pur Java Driver: These are pure Java drivers that commun
icate directly with the vendor's database. They do this by converting JDBC comma
nds
directly into the database engine's native protocol. This driver has no addition
al translation or middleware layer, which improves performance tremendously.

-q What restrictions are placed on method overloading?

ans --- Two methods may not have the same name and argument list but different r
eturn types.

q - Can try statements be nested?


ans -Try statements may be nested.

q-Why do threads block on I/O?


ans - Threads block on i/o (that is enters the waiting state) so that other thre
ads may executewhile the i/oOperation is performed

Question: How are this() and super() used with constructors?

ans -- this() is used to invoke a constructor of the same class. super() is use
d to invoke a superclass constructor.

Question: How many methods in the Externalizable interface?


ans -- There are two methods in the Externalizable interface. You have to implem
ent these two methods in order to make your class externalizable. These two meth
ods are
readExternal() and writeExternal().

q -- Question: 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.

q - What is the purpose of the wait(), notify(), and notifyAll() methods?


ans -- The wait(), notify(), and notifyAll() methods are used to provide an effi
cient way forthreads to wait for a shared resource. When a thread executes an ob
ject's wait() method, it enters the waiting state. It only enters the ready stat
e after another thread invokes the object's notify() or notifyAll() methods.

q -- Question: What's new with the stop(), suspend() and resume() methods in JD
K 1.2?
ans -- The stop(), suspend() and resume() methods have been deprecated in JDK 1.
2.

q-- What method is invoked to cause an object to begin executing as a separateth


read?
ans --
Answer The start() method of the Thread class is invoked to cause an object to
begin executing as a separate thread.

q --

ans --

Question: Why do you create interfaces, and when MUST you use one? Added: 10/1
3/2004
Answer: You would create interfaces when you have two or more functionalities t
alking to each other. Doing it this way help you in creating a protocol between
the parties involved.

Question: How to make application thread-safe ? Added: 10/13/2004


Answer: You should use the word synchronized to mark the critical section of co
de. You may also use other methods of thread synchronization (see wait(), notify
(), notifyAll() etc.
Question: Are constructors inherited? Can a subclass call the parent's class co
nstructor? When? Added: 10/13/2004

Answer: You cannot inherit a constructor. That is, you cannot create a instance
of a subclass using a constructor of one of it's superclasses. One of the main
reasons is because you
probably don't want to overide the superclasses constructor, which would be poss
ible if they were inherited. By giving the developer the ability to override a s
uperclasses
constructor you would erode the encapsulation abilities of the language.

Question: Can an exception be rethrown? Added: 10/13/2004


Answer: Yes, an exception can be rethrown.

Question: Can a lock be acquired on a class? Added: 10/14/2004


Answer: Yes, a lock can be acquired on a class. This lock is acquired on the cl
ass's Class object.

Question: Can a for statement loop indefinitely? Added: 10/14/2004


Answer: Yes, a for statement can loop indefinitely. For example, consider the f
ollowing:for(;;) ;

Answer: Yes, a for statement can loop indefinitely.


For example, consider the following:
for(;;) ;

Question: Can a double value be cast to a byte? Added: 10/14/2004


Answer: Yes, a double value can be cast to a byte.

Question: How many methods do u implement if implement the Serializable Interfa


ce? Added: 10/13/2004
Answer: The Serializable interface is just a "marker" interface, with no method
s of its own to implement.

Question: What happens when you add a double value to a String? Added: 10/13/2
004
Answer: The result is a String object.

Question: What happens when you add a double value to a String? Added: 10/17/2
004
Answer: The result is a String object.

Question: What happens when you add a double value to a String? Added: 10/18/2
004
Answer: The result is a String object.

Question: What is the ResourceBundle class? Added: 10/13/2004


Answer: The ResourceBundle class is used to store locale-specific resources tha
t can be loaded bya program to tailor the program's appearance to the particular
locale in which it is
being run.

Question: What is the ResourceBundle class? Added: 10/18/2004


Answer: The ResourceBundle class is used to store locale-specific resources tha
t can be loaded bya program to tailor the program's appearance to the particular
locale in which it is being run.

Question: What is the ResourceBundle class? Added: 10/13/2004


Answer: The ResourceBundle class is used to store locale-specific resources tha
t can be loaded by a program to tailor the program's appearance to the particula
r locale in which it is
being run.
Question: What value does readLine() return when it has reached the end of a fi
le? Added: 10/14/2004
Answer: The readLine() method returns null when it has reached the end of a fil
e.
Question: What value does readLine() return when it has reached the end of a fi
le? Added: 10/23/2004
Answer: The readLine() method returns null when it has reached the end of a fil
e.
Question: What is the difference between the Reader/Writer class hierarchy and
the InputStream/OutputStream class hierarchy?
Answer: The Reader/Writer class hierarchy is character-oriented, and the InputS
tream/OutputStream class hierarchy is byte-oriented.
Question: What is the difference between the Reader/Writer class hierarchy and
the InputStream/OutputStream class hierarchy?
Answer: The Reader/Writer class hierarchy is character-oriented, and the InputS
tream/OutputStream class hierarchy is byte-oriented.

Question: What value does read() return when it has reached the end of a file?
Added: 10/14/2004
Answer: The read() method returns -1 when it has reached the end of a file.

Question: What is the range of the short type? Added: 10/14/2004


Answer: The range of the short type is -(2^15) to 2^15 - 1.

Question: What is the purpose of the System class? Added: 10/13/2004


Answer: The purpose of the System class is to provide access to system resource
s.

Question: What is the purpose of the Runtime class? Added: 10/14/2004


Answer: The purpose of the Runtime class is to provide access to the Java runti
me system.

Question: What is the purpose of garbage collection? Added: 10/13/2004


Answer: The purpose of garbage collection is to identify and discard objects th
at are no longerneeded by a programso that their resources may be reclaimed and
reused.
Question: What is the purpose of finalization? Added: 10/14/2004
Answer: The purpose of finalization is to give an unreachable object the opport
unity to performany clean up processing before the object is garbage collected.

Question: What is the difference between the prefix and postfix forms of the ++
operator? Added: 10/13/2004
Answer: The prefix form performs the increment operation and returns the value
of the increment operation. The postfix form returns the current value all of th
e expression and then performs the increment operation onthat value.

Question: What is the preferred size of a component? Added: 10/14/2004


Answer: The preferred size of a component is the minimum component size that wi
ll allow the component to display normally.

Question: What is the preferred size of a component? Added: 10/23/2004


Answer: The preferred size of a component is the minimum component size that wi
ll allow the component to display normally.

Question: Which containers use a FlowLayout as their default layout? Added: 10


/14/2004
Answer: The Panel and Applet classes use the FlowLayout as their default layout
.

Question: Which containers use a FlowLayout as their default layout? Added: 10


/23/2004
Answer: The Panel and Applet classes use the FlowLayout as their default layout
.

Question: What is the difference between the paint() and repaint() methods? Ad
ded: 10/18/2004
Answer: The paint() method supports painting via a Graphics object. The repaint
() method is usedto cause paint() to be invoked by the AWT painting thread.
Question: How does multithreading take place on a computer with a single CPU?
Added: 10/13/2004
Answer: The operating system's task scheduler allocates execution time to multi
ple tasks. By quickly switching between executing tasks, it creates the impressi
on that tasks execute
sequentially.

Question: For which statements does it make sense to use a label? Added: 10/13
/2004
Answer: The only statements for which it makes sense to use a label are those s
tatements that canenclose a break orcontinue statement.

Question: What class allows you to read objects directly from a stream? Added:
10/13/2004
Answer: The ObjectInputStream class supports the reading of objects from input
streams.

Question: What class allows you to read objects directly from a stream? Added:
10/13/2004
Answer: The ObjectInputStream class supports the reading of objects from input
streams.

Question: What are the Object and Class classes used for? Added: 10/13/2004
Answer: The Object class is the highest-level class in the Java class hierarchy
. The Class class is used to represent the classes and interfaces that are loade
d by a Java program.

Question: Which class is extended by all other classes? Added: 10/23/2004


Answer: The Object class is extended by all other classes.

Question: Is null a keyword? Added: 10/14/2004


Answer: The null value is not a keyword.

Question: Which non-Unicode letter characters may be used as the first characte
r of an identifier? Added: 10/13/2004
Answer: The non-Unicode letter characters $ and _ may appear as the first chara
cter of an identifier.

Question: Which non-Unicode letter characters may be used as the first characte
rof an identifier? Added: 10/18/2004
Answer: The non-Unicode letter characters $ and _ may appear as the first chara
cter of an identifier.

Question: What is the Map interface? Added: 10/13/2004


Answer: The Map interface replaces the JDK 1.1 Dictionary class and is used ass
ociate keys with values.

Question: In Java, You can create a String object as:


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 is this not compulsory in String's case? Added: 10/13/2004

Answer: The main reason you cannot create a button by Button bt1= "abc"; is bec
ause "abc" is a literal string (something slightly different than a String objec
t, bytheway)and bt1 is a
Button object. That simple. The only object in Java that can be assigned a liter
al String is java.lang.String. Important to note that you are NOT calling a java
.lang.String
constuctor when you type String s = "abc";
For example
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.

Question: What is the Locale class? Added: 10/14/2004


Answer: The Locale class is used to tailor program output to the conventions of
a particular geographic, political, or cultural region.

Question: What is the List interface? Added: 10/23/2004


Answer: The List interface provides support for ordered collections of objects.
Question: What are the legal operands of the instanceof operator? Added: 10/13
/2004
Answer: The left operand is an object reference or null value and the right ope
rand is a class,interface, or array type.

Question: What are the legal operands of the instanceof operator? Added: 10/18
/2004
Answer: The left operand is an object reference or null value and the right ope
rand is a class, interface, or array type.

Question: What is JNI? Added: 8/8/2005


Answer: The JNI is used to write native methods to handle situations when an ap
plication cannot be written entirely in the Java programming language such as wh
en the standard Java class library does not support the platform - dependent fea
tures or program library. It is also used to modify an existing application, wri
tten in another programming language, to be accessible to Java applications.
The JNI is for programmers who must take advantage of platform - specific functi
onality outside of the Java Virtual Machine. Because of this, it is recommended
that only experienced programmers should attempt to write native methods or use
the Invocation API!

Question: What is the difference between the JDK 1.02 event model and the event
delegation model introduced with JDK 1.1? Added: 10/13/2004
Answer: The JDK 1.02 event model uses an event inheritance or bubbling approach
. In this model, components are required to handle their own events. If they do
not handle a
particular event, the event is inherited by (orbubbled up to) the component's co
ntainer. The container then either handles the event orit is bubbled up to its c
ontainer and so
on, until the highest-level container has been tried.In the event-delegation mod
el, specific objects are designated as event handlers for GUI components.These o
bjects
implement event-listener interfaces. The event-delegation model is more efficien
t than the event-inheritance model because it eliminates the processing required
to support
the bubbling of unhandled events.

Question: What is JDBC? Describe the steps needed to execute a SQL query using
JDBC. Added: 10/13/2004
Answer: The JDBC is a pure Java API used to execute SQL statements. It provides
a set of classes and interfaces that can be used by developers to write databas
e applications.
The steps needed to execute a SQL query using JDBC:
1. Open a connection to the database.
2. Execute a SQL statement.
3. Process th results.
4. Close the connection to the database.

Question: What is the highest-level event class of the event-delegation model?


Added: 10/13/2004
Answer: The java.util.EventObject class is the highest-level class in the event
-delegation class hierarchy.

Question: What is the highest-level event class of the event-delegation model?


Added: 10/23/2004
Answer: The java.util.EventObject class is the highest-level class in the event
-delegation class hierarchy.

Question: Which package is always imported by default? Added: 10/13/2004


Answer: The java.lang package is always imported by default.

Question: What class is the top of the AWT event hierarchy? Added: 10/14/2004
Answer: The java.awt.AWTEvent class is the highest-level class in the AWT event
-classhierarchy.

Question: What class of exceptions are generated by the Java run-time system?
Added: 10/13/2004
Answer: The Java runtime system generates RuntimeException and Error exceptions
.
Question: Describe, in general, how java's garbage collector works? Added: 10/
13/2004
Answer: The Java runtime environment deletes objects when it determines that th
ey are no longer being used. This process is known as garbage collection. The Ja
va runtime
environment supports a garbage collector that periodically frees the memory used
by objects that are no longer needed. The Java garbage collector is a mark-swee
p
garbage collector that scans Java's dynamic memory areas for objects, marking th
ose that are referenced. After all possible paths to objects are investigated, t
hose objects
that are not marked (i.e. are not referenced) are known to be garbage and are co
llected.

Question: What is an Iterator interface? Added: 10/23/2004


Answer: The Iterator interface is used to step through the elements of a Collec
tion.

Question: What is the difference between an if statement and a switch statement


? Added: 10/17/2004
Answer: The if statement is used to select among two alternatives. It uses a bo
olean expression to decide which alternative should be executed. The switch stat
ement is used to select among multiple alternatives. It uses an int expression t
o determine which alternative should be executed.

Question: What are the high-level thread states? Added: 10/14/2004


Answer: The high-level thread states are ready, running, waiting, and dead.

Question: What class is the top of the AWT event hierarchy? Added: 10/14/2004
Answer: The java.awt.AWTEvent class is the highest-level class in the AWT event
-classhierarchy.

Question: What class is the top of the AWT event hierarchy? Added: 10/23/2004
Answer: The java.awt.AWTEvent class is the highest-level class in the AWT event
-class hierarchy.

Question: What class of exceptions are generated by the Java run-time system?
Added: 10/13/2004
Answer: The Java runtime system generates RuntimeException and Error exceptions
.
Question: What class of exceptions are generated by the Java run-time system?
Added: 10/18/2004
Answer: The Java runtime system generates RuntimeException and Error exceptions
.

Question: Describe, in general, how java's garbage collector works? Added: 10/
13/2004
Answer: The Java runtime environment deletes objects when it determines that th
ey are no longer being used. This process is known as garbage collection. The Ja
va runtime
environment supports a garbage collector that periodically frees the memory used
by objects that are no longer needed. The Java garbage collector is a mark-swee
p
garbage collector that scans Java's dynamic memory areas for objects, marking th
ose that are referenced. After all possible paths to objects are investigated, t
hose objects
that are not marked (i.e. are not referenced) are known to be garbage and are co
llected.
CoolInterview.com
Question: What is an Iterator interface? Added: 10/14/2004
Answer: The Iterator interface is used to step through the elements of a Collec
tion.

Question: What is the difference between an if statement and a switch statement


? Added: 10/17/2004
Answer: The if statement is used to select among two alternatives. It uses a bo
olean expression to decide which alternative should be executed. The switch stat
ement is used to select among multiple alternatives. It uses an int expression t
o determine which alternative should be executed.

Question: What are the high-level thread states?


Answer: The high-level thread states are ready, running, waiting, and dead.

Question: What is the difference between the Font and FontMetrics classes? Add
ed: 10/14/2004
Answer: The FontMetrics class is used to define implementation-specific propert
ies, such as ascent and descent, of a Font object.

Question: When is the finally clause of a try-catch-finally statement executed?


Added: 10/13/2004
Answer: The finally clause of the try-catch-finally statement is always execute
d unless the threadof executionterminates or an exception occurs within the exec
ution of the finally
clause.

Question: What is the purpose of the finally clause of a try-catch-finally stat


ement? Added: 10/23/2004
Answer: The finally clause is used to provide the capability to execute code no
matter whether ornot an exception is thrown or caught.

Question: What is the purpose of the File class? Added: 10/13/2004


Answer: The File class is used to create objects that provide access to the fil
es and directories of alocal file system.

Question: What is the difference between the File and RandomAccessFile classes?
Added: 10/18/2004
Answer: The File class encapsulates the files and directories of the local file
system. The RandomAccessFile class provides the methods needed to directly acce
ss data contained in any part of a file.

Question: What happens if a try-catch-finally statement does not have a catch c


lause to handle an exception that is thrown within the body of the try statement
? Added: 10/13/2004
Answer: The exception propagates up to the next higher level try-catch statemen
t (if any) or results in the program's termination..

till page 18

Question: Why do you create interfaces, and when MUST you use one? Added: 10/1
3/2004
Answer: You would create interfaces when you have two or more functionalities t
alking to each other. Doing it this way help you in creating a protocol between
the parties involved.

Question: How to make application thread-safe ? Added: 10/13/2004


Answer: You should use the word synchronized to mark the critical section of co
de. You may also use other methods of thread synchronization (see wait(), notify
(), notifyAll() etc.

Question: Are constructors inherited? Can a subclass call the parent's class co
nstructor? When? Added: 10/13/2004
Answer: You cannot inherit a constructor. That is, you cannot create a instance
of a subclass using a constructor of one of it's superclasses. One of the main
reasons is because you
probably don't want to overide the superclasses constructor, which would be poss
ible if they were inherited. By giving the developer the ability to override a s
uperclasses
constructor you would erode the encapsulation abilities of the language.

Question: Can an exception be rethrown? Added: 10/13/2004


Answer: Yes, an exception can be rethrown.

Question: Can an exception be rethrown? Added: 10/18/2004


Answer: Yes, an exception can be rethrown.

Question: Can a lock be acquired on a class? Added: 10/14/2004


Answer: Yes, a lock can be acquired on a class. This lock is acquired on the cl
ass's Class object.

Question: Can a for statement loop indefinitely? Added: 10/14/2004


Answer: Yes, a for statement can loop indefinitely. For example, consider the f
ollowing:for(;;) ;

Question: Can a double value be cast to a byte? Added: 10/14/2004


Answer: Yes, a double value can be cast to a byte.

Question: Why do you create interfaces, and when MUST you use one? Added: 10/1
3/2004
Answer: You would create interfaces when you have two or more functionalities t
alking to each other. Doing it this way help you in creating a protocol between
the parties involved.

Question: How to make application thread-safe ? Added: 10/13/2004


Answer: You should use the word synchronized to mark the critical section of co
de. You may also use other methods of thread synchronization (see wait(), notify
(), notifyAll() etc.
Question: Are constructors inherited? Can a subclass call the parent's class co
nstructor? When? Added: 10/13/2004
Answer: You cannot inherit a constructor. That is, you cannot create a instance
of a subclass using a constructor of one of it's superclasses. One of the main
reasons is because you
probably don't want to overide the superclasses constructor, which would be poss
ible if they were inherited. By giving the developer the ability to override a s
uperclasses
constructor you would erode the encapsulation abilities of the language.

Question: Can an exception be rethrown? Added: 10/13/2004


Answer: Yes, an exception can be rethrown.
CoolInterview.com

Question: Can a lock be acquired on a class? Added: 10/14/2004

Answer: Yes, a lock can be acquired on a class. This lock is acquired on the cl
ass's Class object.

Question: Can a double value be cast to a byte? Added: 10/14/2004


Answer: Yes, a double value can be cast to a byte.
Question: How are the elements of a GridLayout organized? Added: 10/18/2004
Answer: The elements of a GridBad layout are of equal size and are laid out usi
ng the squares of a grid.

Question: How are the elements of a CardLayout organized? Added: 10/23/2004


Answer: The elements of a CardLayout are stacked, one on top of the other, like
a deck of cards.

Question: How are the elements of a BorderLayout organized? Added: 10/23/2004


Answer: The elements of a BorderLayout are organized at the borders (North, Sou
th, East, andWest) and the center of a container.

Question: Name the eight primitive Java types? Added: 10/13/2004


Answer: The eight primitive types are byte, char, short, int, long, float, doub
le, and boolean.

Question: Which characters may be used as the second character of an identifier


, but not as the first character of an identifier? Added: 10/23/2004
Answer: The digits 0 through 9 may not be used as the first character of an ide
ntifier but they maybe used after the first character of an identifier.
Question: Which characters may be used as the second character of an identifier
, but notas the first character of an identifier? Added: 10/14/2004
Answer: The digits 0 through 9 may not be used as the first character of an ide
ntifier but they may be used after the first character of an identifier.

Question: What is the Dictionary class? Added: 10/14/2004


Answer: The Dictionary class provides the capability to store key-value pairs.

21

Question: What is the Dictionary class? Added: 10/23/2004


Answer: The Dictionary class provides the capability to store key-value pairs.

Question: To what value is a variable of the boolean type automatically initial


ized? Added: 10/13/2004
Answer: The default value of the boolean type is false.
Question: To what value is a variable of the boolean type automatically initial
ized? Added: 10/18/2004
Answer: The default value of the boolean type is false.

Question: To what value is a variable of the String type automatically initiali


zed? Added: 10/14/2004
Answer: The default value of an String type is null.

Question: To what value is a variable of the String type automatically initiali


zed? Added: 10/23/2004
Answer: The default value of an String type is null.

Question: When does the compiler supply a default constructor for a class? Add
ed: 10/13/2004
Answer: The compiler supplies a default constructor for a class if no other con
structors are provided.

Question: When does the compiler supply a default constructor for a class? Add
ed: 10/18/2004
Answer: The compiler supplies a default constructor for a class if no other con
structors are provided.

Question: What is the Collections API? Added: 10/23/2004


Answer: The Collections API is a set of classes and interfaces that support ope
rations oncollections of objects.
Question: What is the Collection interface? Added: 10/13/2004
Answer: The Collection interface provides support for the implementation of a m
athematical bag -an unorderedcollection of objects that may contain duplicates.

22

Question: Why do you create interfaces, and when MUST you use one? Added: 10/1
3/2004
Answer: You would create interfaces when you have two or more functionalities t
alking to each other. Doing it this way help you in creating a protocol between
the parties involved.
Question: How to make application thread-safe ? Added: 10/13/2004
Answer: You should use the word synchronized to mark the critical section of co
de. You may also use other methods of thread synchronization (see wait(), notify
(), notifyAll() etc.

Question: Are constructors inherited? Can a subclass call the parent's class co
nstructor? When? Added: 10/13/2004
Answer: You cannot inherit a constructor. That is, you cannot create a instance
of a subclass using a constructor of one of it's superclasses. One of the main
reasons is because you
probably don't want to overide the superclasses constructor, which would be poss
ible if they were inherited. By giving the developer the ability to override a s
uperclasses
constructor you would erode the encapsulation abilities of the language.

Question: Can an exception be rethrown? Added: 10/13/2004


Answer: Yes, an exception can be rethrown.

Question: Can a lock be acquired on a class? Added: 10/14/2004


Answer: Yes, a lock can be acquired on a class. This lock is acquired on the cl
ass's Class object.

Question: Can a for statement loop indefinitely? Added: 10/23/2004


Answer: Yes, a for statement can loop indefinitely.
For example, consider the following:
for(;;) ;