Common Java Interview QuestionsSend your Question/Answer Java and C++
Some of the similarities and differences are in the table:
Basic concepts
Serialization is a way to convert objects (including complex data structures
such as lists and trees) into a stream of bytes.
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.
One should use something like
synchronized(this){...}
Of course. You should write something like that:
public,private,protected,package.
User interface
The AWT toolkit is an interface between the abstract window layer and a specific
windowing implementation.
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.
The biggest advantage is the standard way of implementing the user interface for
cross-platform application. Disadvantages are:
- Challenge to create a custom layout if the standard one does not fit in your model - Inability to use native UI features of concrete operating system that might be quite useful especially for complex UI tasks (however, this is against the Java philosophy and quite understandable drawback)
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.)
Java Beans
According to JavaSoft, "A Java Bean is a reusable software component that
can be manipulated visually in a builder tool."
Networking
Java 1.2 promises full CORBA IDL support.
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 platform-independent.
Threads
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.
Deployment
JAR files bundle .class files and optimize applet downloads.
|