Advanced Java Questions and Answer for Interview
111. What advantage do Java's layout managers provide over 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 accomodate platform-specific differences among windowing systems.
112. What is the Collection interface?
Collection interface provides support for the implementation of a mathematical bag - an unordered collection of objects that may contain duplicates.
113. What modifiers can be used with a local inner class?
A local inner class may be
114. What is the difference between static and non-static variables?
A static variable is associated with the class as a whole rather than with specific instances of a class.
Non-static variables take on unique values with each object instance.
115. What is the difference between the paint() and repaint() methods?
paint() method supports painting via a Graphics object. The
repaint() method is used to cause
paint() to be invoked by the AWT painting thread.
116. What is the purpose of the File class?
File class is used to create objects that provide access to the files and directories of a local file system.
117. Can an exception be rethrown?
Yes, an exception can be rethrown.
118. Which Math method is used to calculate the absolute value of a number?
abs() method is used to calculate absolute values.
119. How does multithreading take place on a computer with a single CPU?
The operating system's task scheduler allocates execution time to multiple tasks. By quickly switching between executing tasks, it creates the impression that tasks execute sequentially.
120. When does the compiler supply a default constructor for a class?
The compiler supplies a default constructor for a class if no other constructors are provided.