1. Described heavy weight components mean in Java Programming?

Heavy weight components like Abstract Window Toolkit (AWT), depend on the local windowing toolkit. For example, java.awt.Button is a heavy weight component, when it is running on the Java platform for Unix platform, it maps to a real Motif button. In this relationship, the Motif button is called the peer to the java.awt.Button. If you create two Buttons, two peers and hence two Motif Buttons are also created. The Java platform communicates with the Motif Buttons using the Java Native Interface. For each and every component added to the application, there is an additional overhead tied to the local windowing system, which is why these components are called heavyweight.

2. Can you please explain the difference between Boolean & operator and the && operator in Java Programming?

If an expression involving the Boolean & operator is evaluated, both operands are evaluated. Then the & operator is applied to the operand. When an expression involving the && operator is evaluated, the first operand is evaluated. If the first operand returns a value of true then the second operand is evaluated. The && operator is then applied to the first and second operands. If the first operand evaluates to false, the evaluation of the second operand is skipped.
Operator & has no chance to skip both sides evaluation and && operator does. If asked why, give details as above.

3. Does the garbage collection guarantee that a program will not run out of memory?

No, it doesn't. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection.

4. Described the elements of a GridBagLayout organized in Java Programming?

The elements of a GridBagLayout are organized according to a grid. However, the elements are of different sizes and may occupy more than one row or column of the grid. In addition, the rows and columns may have different sizes.

5. What advantage do Java's layout managers provide over the traditional windowing systems?

Java uses layout managers to lay out components in a consistent manner across all windowing platforms. Since Java's layout managers aren't tied to absolute sizing and positioning, they are able to accommodate platform-specific differences among windowing systems.

6. How a GUI component handle its own events in Java Programming?

A component can handle its own events by implementing the required event-listener interface and adding itself as its own event listener.

7. Name primitive Java types?

The primitive types are byte, char, short, int, long, float, double, and boolean.

8. Explain the difference between Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy in Java Programming?

The Reader/Writer class hierarchy is character-oriented, and the InputStream/OutputStream class hierarchy is byte-oriented.

9. Does a class inherit constructors of its superclass in Java Programming?

A class does not inherit constructors from any of its superclasses.

10. Define Map interface in Java Programming?

The Map interface replaces the JDK 1.1 Dictionary class and is used associate keys with values.

Download Interview PDF

11. If the a class is declared without any access modifiers, where may the class be accessed in Java Programming?

A class that is declared without any access modifiers is said to have package or friendly access. This means that the class can only be accessed by other classes and interfaces that are defined within the same package.

12. Which classes of exceptions may be caught by a catch clause in Java Programming?

A catch clause can catch any exception that may be assigned to the Throwable type. This includes the Error and Exception types.

13. Can you please explain the difference between preemptive scheduling and time slicing in Java Programming?

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.

14. What happens when a thread cannot acquire lock on an object in Java Programming?

If a thread attempts to execute a synchronized method or synchronized statement and is unable to acquire an object's lock, it enters the waiting state until the lock becomes available.

15. Can you please explain the difference between Font and FontMetrics classes in Java Programming?

The FontMetrics class is used to define implementation-specific properties, such as ascent and descent, of a Font object.

16. What are peerless components?

The peerless components are called light weight components.

17. Which package has the light weight components in Java Programming?

javax.Swing package. All components in Swing, except JApplet, JDialog, JFrame and JWindow are lightweight components in Java Programming.

18. When an object reference be cast to an interface reference in Java Programming?

An object reference be cast to an interface reference when the object implements the referenced interface.

19. Can you please explain the difference between Window and a Frame in Java Programming?

The Frame class extends Window to define a main application window that can have a menu bar.

20. Can you please explain the difference between static and a non-static inner class in Java Programming?

A non-static inner class may have object instances that are associated with instances of the class's outer class. A static inner class does not have any object instances.

21. Described object's lock and which object's have locks in Java Programming?

An object's lock is a mechanism that is used by multiple threads to obtain synchronized access to the object. A thread may execute a synchronized method of an object only after it has acquired the object's lock. All objects and classes have locks. A class's lock is acquired on the class's Class object.

22. Described abstract method in Java Programming?

An abstract method is a method whose implementation is deferred to a subclass in Java Programming.

23. What are high-level thread states in Java Programming?

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

24. What must class do to implement an interface in Java Programming?

It must provide all of the methods in the interface and identify the interface in its implements clause.

25. Described the purpose of the wait(), notify(), and notifyAll() methods in Java Programming?

The wait(),notify(), and notifyAll() methods are used to provide an efficient way for threads to communicate each other in Java Programming.

Download Interview PDF

26. What is the purpose of finally clause of a try-catch-finally statement in Java Programming?

The finally clause is used to provide the capability to execute code no matter whether or not an exception is thrown or caught.

27. Described locale class in Java Programming?

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

28. What is the purpose of Runtime class in Java Programming?

The purpose of the Runtime class is to provide access to the Java runtime system in Java Programming.

29. Described the purpose of System class in Java Programming?

The purpose of the System class is to provide access to system resources in Java Programming.

30. Which Container method is used to cause container to be laid out and redisplayed in Java Programming?

validate();
Container method is used to cause a container to be laid out and redisplayed in Java Programming.

31. Described properties class in Java Programming?

The properties class is a subclass of Hashtable that can be read from or written to a stream. It also provides the capability to specify a set of default values to be used.

32. Described Gregorian Calendar class in Java Programming?

The GregorianCalendar provides support for traditional Western calendars in Java Programming.

33. What is SimpleTimeZone class in Java Programming?

The SimpleTimeZone class provides support for a Gregorian calendar in Java Programming.

34. Which invokes a thread's run() method in Java Programming?

After a thread is started, via its start() method or that of the Thread class, the JVM invokes the thread's run() method when the thread is initially executed.

35. Can anonymous class be declared as implementing an interface and extending a class in Java Programming?

An anonymous class may implement an interface or extend a superclass, but may not be declared to do both.

36. What is purpose of finalization in Java Programming?

The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected.

37. Which class is superclass for every class in Java Programming?

Object class is the superclass for every class in Java Programming.

38. Which component subclasses that support painting in Java Programming?

The Canvas, Frame, Panel, and Applet classes support painting.

39. Described native method in Java Programming?

A native method is a method that is implemented in a language other than Java.

40. How to write a loop indefinitely in Java Programming?

for(;;)-for loop; while(true)-always true, etc.

Download Interview PDF

41. How many bits are used to represent the Unicode, ASCII, UTF-16, and UTF-8 characters in Java Programming?

Unicode requires 16 bits and ASCII require 7 bits. Although the ASCII character set uses only 7 bits, it is usually represented as 8 bits. UTF-8 represents characters using 8, 16, and 18 bit patterns. UTF-16 uses 16-bit and larger bit patterns.

42. Can you please explain the difference between yielding and sleeping in Java Programming?

When a task invokes its yield() method, it returns to the ready state. When a task invokes its sleep() method, it returns to the waiting state.

43. Is the size of a keyword in Java Programming?

The sizeof operator is not a keyword in Java Programming.

44. Described wrapped classes in Java Programming?

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

45. Does Java handle integer overflows and underflows?

It uses those low order bytes of the result that can fit into the size of the type allowed by the operation.

46. What is Vector class in Java Programming?

The Vector class in Java Programming provides the capability to implement a growable array of objects.

47. Which modifiers may be used with an inner class that is a member of an outer class in Java Programming?

A (non-local) inner class may be declared as public, protected, private, static, final, or abstract.

48. Suppose if a method is declared as protected, where may the method be accessed in Java Programming?

A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared.

49. What is Iterator interface in Java Programming?

The Iterator interface is used to step through the elements of a Collection.

50. Which containers is use a border layout as their default layout?

The window, Frame and Dialog classes use a border layout as their default layout in Java Programming.

51. Which method is used to specify a container's layout in Java Programming?

The setLayout() method is used to specify a container's layout in Java Programming.

52. Which state does a thread enter when it terminates its processing in Java Programming?

When a thread terminates its processing, it enters the dead state.

53. What is Collections API in Java Programming?

The Collections API is a set of classes and interfaces that support operations on collections of objects.

54. Define Llist interface in Java Programming?

The List interface provides support for ordered collections of objects.

55. Can a lock be acquired on class in Java Programming?

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

Download Interview PDF

56. Which containers use FlowLayout as their default layout in Java Programming?

The Panel and Applet classes use the FlowLayout as their default layout.

57. Described transient variable?

A transient variable is a variable that may not be serialized.

58. What's new with stop(), suspend() and resume() methods in JDK 1.2?

The stop(), suspend() and resume() methods have been deprecated in JDK 1.2.

59. Define preferred size of a component in Java Programming?

The preferred size of a component is the minimum component size that will allow the component to display normally.

60. Which three ways in which a thread can enter the waiting state in Java Programming?

A thread can enter the waiting state by invoking its sleep() method, by blocking on I/O, by unsuccessfully attempting to acquire an object's lock, or by invoking an object's wait() method. It can also enter the waiting state by invoking its (deprecated) suspend() method.

61. Described synchronized methods and synchronized statements in Java Programming?

Synchronized methods are methods that are used to control access to an object. A thread only executes a synchronized method after it has acquired the lock for the method's object or class. Synchronized statements are similar to synchronized methods. A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement.

62. Described synchronization and why is it important in Java Programming?

With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared 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 causes dirty data and leads to significant errors.

63. How Observer and Observable used in Java Programming?

Objects that subclass the Observable class maintain a list of observers. When an Observable object is updated it invokes the update() method of each of its observers to notify the observers that it has changed state. The Observer interface is implemented by objects that observe Observable objects.