Dear Readers, Welcome to Advanced Java Interview Questions and Answers have been designed specially to get you acquainted with the nature of questions you may encounter during your Job interview for the subject of Advanced Java. These Advanced Java Questions are very important for campus placement test and job interviews. As per my experience good interviewers hardly plan to ask any particular questions during your Job interview and these model questions are asked in the online technical test and interview of many IT companies.
A transient variable is a variable that may not be serialized.
The Window, Frame and Dialog classes use a border layout as their default layout.
Threads block on I/O (that is enters the waiting state) so that other threads may execute while the I/O Operation is performed.
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.
The null is not a keyword.
The preferred size of a component is the minimum component size that will allow the component to display normally.
The Panel and Applet classes use the FlowLayout as their default layout.
When a thread terminates its processing, it enters the dead state.
The Collections API is a set of classes and interfaces that support operations on collections of objects.
The digits 0 through 9 may not be used as the first character of an identifier but they may be used after the first character of an identifier.
The List interface provides support for ordered collections of objects.
It uses those low order bytes of the result that can fit into the size of the type allowed by the operation.
The Vector class provides the capability to implement a growable array of objects
A (non-local) inner class may be declared as public, protected, private, static, final, or abstract.
The Iterator interface is used to step through the elements of a Collection.
The >> operator carries the sign bit when shifting right. The >>> zero-fills bits that have been shifted out.
setBounds() method is used to set the position and size of a component.
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.
The EventObject class and the EventListener interface support event processing.
The sizeof operator is not a keyword.
Wrapped classes are classes that allow primitive types to be accessed as objects.
Garbage collection does not guarantee that a program will not run out of memory. 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.
A package statement must appear as the first line in a source code file (excluding blank lines and comments).
Panel.
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.
The Canvas, Frame, Panel, and Applet classes support painting.
The readLine() method returns null when it has reached the end of a file.
Window.
Clipping is the process of confining paint operations to a limited area or shape.
A native method is a method that is implemented in a language other than Jav
Yes, a for statement can loop indefinitely. For example, consider the following: for(;;) ;
An objects finalize() method cannot be invoked by the garbage collector while the object is still reachable. However, an objects finalize() method may be invoked by other objects.
The setLayout() method is used to specify a containers layout.
The stop(), suspend() and resume() methods have been deprecated in JDK 1.2.
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 objects value.
Yes, a lock can be acquired on a class. This lock is acquired on the classes Class object..
Order of precedence determines the order in which operators are evaluated in expressions. Associatity determines whether an expression is evaluated left-to-right or right-to-left.
A thread enters the waiting state when it blocks on I/O.
The default value of an String type is null.
If a checked exception may be thrown within the body of a method, the method must either catch the exception or declare it in its throws clause.
The CheckboxMenuItem class extends the MenuItem class to support a menu item that may be checked or unchecked.
A tasks priority is an integer value that identifies the relative order in which it should be executed with respect to other tasks. The scheduler attempts to schedule higher priority tasks before lower priority tasks.
The javawt.AWTEvent class is the highest-level class in the AWT event-class hierarchy.
A thread is in the ready state after it has been created and started.
An anonymous class may implement an interface or extend a superclass, but may not be declared to do both.
MenuItem.
The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected.
Object.
After a thread is started, via its start() method or that of the Thread class, the JVM invokes the threads run() method when the thread is initially executed.
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.
Box.Filler, Button, Canvas, Checkbox, Choice, Container, Label, List, Scrollbar, or TextComponent.
The GregorianCalendar class provides support for traditional Western calendars.
validate() method is used to cause a container to be laid out and redisplayed.
The purpose of the Runtime class is to provide access to the Java runtime system.
An objects finalize() method may only be invoked once by the garbage collector.
The finally clause is used to provide the capability to execute code no matter whether or not an exception is thrown or caught.
A programs main() method takes an argument of the String[] type.
The = operator is right associative.
Yes, a double value can be cast to a byte.
It must provide all of the methods in the interface and identify the interface in its implements clause.
The start() method of the Thread class is invoked to cause an object to begin executing as a separate thread.
TextField and TextAre
Frame.
Commas are used to separate multiple statements within the initialization and iteration parts of a for statement.
The wait(), notify(), and notifyAll() methods are used to provide an efficient way for threads to wait for a shared resource. When a thread executes an objects wait() method, it enters the waiting state. It only enters the ready state after another thread invokes the objects notify() or notifyAll() methods.
An abstract method is a method whose implementation is deferred to a subclass.
A Canvas object provides access to a Graphics object via its paint() method.
The high-level thread states are ready, running, waiting, and dead.
If no public class or interface is defined within a source code file, then the file must take on a name that is different than its classes and interfaces. Source code files use the .java extension.
The read() method returns -1 when it has reached the end of a file.
No. An object cannot be cast to a primitive value.
A non-static inner class may have object instances that are associated with instances of the classes outer class. A static inner class does not have any object instances.
String objects are constants. StringBuffer objects are not constants.
A private variable may only be accessed within the class in which it is declared.
An objects 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 objects lock. All objects and classes have locks. A classes lock is acquired on the classes Class object.
The Dictionary class provides the capability to store key-value pairs.
The elements of a BorderLayout are organized at the borders (North, South, East, and West) and the center of a container.
It is referred to as the modulo or remainder operator. It returns the remainder of dividing the first operand by the second operand.
The thread could be implemented by using runnable interface or by inheriting from the Thread class. The former is more advantageous, Because when you are going for multiple inheritance.the only interface can help.
AWT are heavy-weight componenets. Swings are light-weight components. Hence swing works faster than AWT.
The HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and permits nulls. (HashMap allows null values as key and value whereas Hashtable doesnt allow). HashMap does not guarantee that the order of the map will remain constant over time. HashMap is unsynchronized and Hashtable is synchronized.
Map is Interface and Hashmap is class that implements that.
A final class cant be extended ie., final class may not be subclassed. A final method cant be overridden when its class is inherited. You cant change value of a final variable (is a constant).
The program compiles properly but at runtime it will give “Main method not public.” message.
Program compiles. But at runtime throws an error “NoSuchMethodError”.
Program compiles and runs properly.
Program compiles but throws a runtime error “NoSuchMethodError”.
No the program fails to compile. The compiler says that the main method is already defined in the class.
No. It is by default loaded internally by the JVM.
One can import the same package or same class multiple times. Neither compiler nor JVM complains abt it. And the JVM will internally load the class only once no matter how many times you import the same class.
null unless we define it explicitly.
An object reference be cast to an interface reference when the object implements the referenced interface.
The Frame class extends Window to define a main application window that can have a menu bar.
The Object class is extended by all other classes.
A reachable object cannot be garbage collected. Only unreachable objects may be garbage collected.
It is written x ? y : z.
The FontMetrics class is used to define implementation-specific properties, such as ascent and descent, of a Font object.
The fractional part of the result is truncated. This is known as rounding toward zero.
If a thread attempts to execute a synchronized method or synchronized statement and is unable to acquire an objects lock, it enters the waiting state until the lock becomes available.
The Reader/Writer class hierarchy is character-oriented, and the InputStream/OutputStream class hierarchy is byte-oriented.
A catch clause can catch any exception that may be assigned to the Throwable type. This includes the Error and Exception types.
A class that is declared without any access modifiers is said to have package access. This means that the class can only be accessed by other classes and interfaces that are defined within the same package.
The SimpleTimeZone class provides support for a Gregorian calendar.
The Map interface replaces the JDK 1.1 Dictionary class and is used associate keys with values.
A class does not inherit constructors from any of its superclasses.
The only statements for which it makes sense to use a label are those statements that can enclose a break or continue statement.
The purpose of the System class is to provide access to system resources.
setEditable().
The elements of a CardLayout are stacked, one on top of the other, like a deck of cards.
No. It is not a valid java operator.
The eight primitive types are byte, char, short, int, long, float, double, and boolean.
The Class class is used to obtain information about an objects design.
When a window is repainted by the AWT painting thread, it sets the clipping regions to the area of the window that requires repainting.
The String literal “abc” is not a primitive value. It is a String object.
An event-listener interface defines the methods that must be implemented by an event handler for a particular kind of event. An event adapter provides a default implementation of an event-listener interface.
During compilation, the values of each case of a switch statement must evaluate to a value that can be promoted to an int value.
An interface may be declared as public or abstract.
A class is a subclass of itself.
The javutil.EventObject class is the highest-level class in the event-delegation class hierarchy.
The ActionEvent event is generated as the result of the clicking of a button.