java is an Object  Oriented Programming Language. Which is mostly used to develop Windows based Software  as well as Web Based Project. It is good to have good knowledge about a programming language and practical knowledge for developing program in that particular language. In the technical interview for the post of  Java Developer some basic questions are asked. In this post I am telling about questions at basic level. These questions are related to use of this and super Keyword operators, JVM and Jdk, Interface and access specifier, methods , class, java collections, seriazable in java , hastable , jsp servlet etc.

Q             Name Component subclasses that support painting.
A             The Canvas, Frame, Panel, and Applet classes support painting.

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

Q             How can you write a loop indefinitely?
A             for(;;)--for loop; while(true)--always true, etc.

Q             Can an anonymous class be declared as implementing an interface and extending a class?
A             An anonymous class may implement an interface or extend a superclass, but may not be declared to do both.

Q         &nbsbsp;What is the purpose of finalization?
A             The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected.

Q             Which class is the superclass for every class.
A             Object

Q             What is the difference between the Boolean & operator and the && operator?
A             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.

Q             What is the GregorianCalendar class?
A             The GregorianCalendar provides support for traditional Western calendars.

Q             What is the SimpleTimeZone class?
A             The SimpleTimeZone class provides support for a Gregorian calendar.

Q             Which Container method is used to cause a container to be laid out and redisplayed?
A             validate()

Q             What is the Properties class?
A             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.

Q             What is the purpose of the Runtime class?
A             The purpose of the Runtime class is to provide access to the Java runtime system.

Q             What is the purpose of the System class?
A             The purpose of the System class is to provide access to system resources.

Q             What is the purpose of the finally clause of a try-catch-finally statement?
A             The finally clause is used to provide the capability to execute code no matter whether or not an exception is thrown or caught.

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

Q             What must a class do to implement an interface?
A             It must provide all of the methods in the interface and identify the interface in its implements clause.

Q             What is an abstract method?
A             An abstract method is a method whose implementation is deferred to a subclass. Or, a method that has no implementation (an interface of a method).

Q             What is a static method?
A             A static method is a method that belongs to the class rather than any object of the class and doesn't apply to an object or even require that any objects of the class have been instantiated.

Q             What is a protected method?
A             A protected method is a method that can be accessed by any method in its package and inherited by any subclass of its class.

Q             What is the difference between a static and a non-static inner class?
A             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.

Q             What is an object's lock and which object's have locks?
A             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.

Q             When can an object reference be cast to an interface reference?
A             An object reference be cast to an interface reference when the object implements the referenced interface.

Q             What is the difference between a Window and a Frame?
A             The Frame class extends Window to define a main application window that can have a menu bar.

Q             What do heavy weight components mean?
A             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 heavy weight.

Q             Which package has light weight components?
A             javax.Swing package. All components in Swing, except JApplet, JDialog, JFrame and JWindow are lightweight components.

Q             What are peerless components?
A             The peerless components are called light weight components.

Q             What is the difference between the Font and FontMetrics classes?
A             The FontMetrics class is used to define implementation-specific properties, such as ascent and descent, of a Font object.

Q             What happens when a thread cannot acquire a lock on an object?
A             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.

Q             What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?
A             The Reader/Writer class hierarchy is character-oriented, and the InputStream/OutputStream class hierarchy is byte-oriented.

Q             What classes of exceptions may be caught by a catch clause?
A             A catch clause can catch any exception that may be assigned to the Throwable type. This includes the Error and Exception types.

Q             What is the difference between throw and throws keywords?
A             The throw keyword denotes a statement that causes an exception to be initiated. It takes the Exception object to be thrown as argument. The exception will be caught by an immediately encompassing try-catch construction or propagated further up the calling hierarchy.
The throws keyword is a modifier of a method that designates that exceptions may come out of the mehtod, either by virtue of the method throwing the exception itself or because it fails to catch such exceptions that a method it calls may throw.

Q             If a class is declared without any access modifiers, where may the class be accessed?
A             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.

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

Q             Does a class inherit the constructors of its superclass?
A             A class does not inherit constructors from any of its superclasses.

Q             Name primitive Java types.
A             The primitive types are byte, char, short, int, long, float, double, and boolean.

Q             Which class should you use to obtain design information about an object?
A             The Class class is used to obtain information about an object's design.

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

Q             How are the elements of a GridBagLayout organized?
A             The elements of a GridBagLayout are organized according to a grid. However, the elements are of different sizes and may occupy more thanrow or column of the grid. In addition, the rows and columns may have different sizes.

Q             What advantage do Java's layout managers provide over traditional windowing systems?
A             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.

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

Q             What is the difference between static and non-static variables?
A             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.

Q             What is the difference between the paint() and repaint() methods?
A             The paint() method supports painting via a Graphics object. The repaint() method is used to cause paint() to be invoked by the AWT painting thread.

Q             What is the purpose of the File class?
A             The File class is used to create objects that provide access to the files and directories of a local file system.

Q             What restrictions are placed on method overloading?
A             Two methods may not have the same name and argument list but different return types.

Q             What restrictions are placed on method overriding?
A             Overridden methods must have the same name, argument list, and return type. The overriding method may not limit the access of the method it overrides. The overriding method may not throw any exceptions that may not be thrown by the overridden method.

Q             What is casting?
A             There are two types of casting, casting between primitive numeric types and casting between object references. Casting between numeric types is used to convert larger values, such as double values, to smaller values, such as byte values. Casting between object references is used to refer to an object by a compatible class, interface, or array type reference.

Q             Name Container classes.
A             Window, Frame, Dialog, FileDialog, Panel, Applet, or ScrollPane

Q             What class allows you to read objects directly from a stream?
A             The ObjectInputStream class supports the reading of objects from input streams.

Q             How are this() and super() used with constructors?
A             this() is used to invoke a constructor of the same class. super() is used to invoke a superclass constructor.

Q             How is it possible for two String objects with identical values not to be equal under the == operator?
A             The == operator compares two objects to determine if they are the same object in memory. It is possible for two String objects to have the same value, but located indifferent areas of memory.

Q             What an I/O filter?
A             An I/O filter is an object that reads from one stream and writes to another, usually altering the data in some way as it is passed from one stream to another.

Q             What is the Set interface?
A             The Set interface provides methods for accessing the elements of a finite mathematical set. Sets do not allow duplicate elements.

Q             What is the List interface?
A             The List interface provides support for ordered collections of objects.

Q             What is the purpose of the enableEvents() method?
A             The enableEvents() method is used to enable an event for a particular object. Normally, an event is enabled when a listener is added to an object for a particular event. The enableEvents() method is used by objects that handle events by overriding their event-dispatch methods.

Q             What is the difference between the File and RandomAccessFile classes?
A             The File class encapsulates the files and directories of the local file system. The RandomAccessFile class provides the methods needed to directly access data contained in any part of a file.

Q             What interface must an object implement before it can be written to a stream as an object?
A             An object must implement the Serializable or Externalizable interface before it can be written to a stream as an object.

Q             What is the ResourceBundle class?
A             The ResourceBundle class is used to store locale-specific resources that can be loaded by a program to tailor the program's appearance to the particular locale in which it is being run.

Q             What is the difference between a Scrollbar and a ScrollPane?
A             A Scrollbar is a Component, but not a Container. A ScrollPane is a Container. A ScrollPane handles its own events and performs its own scrolling.

Q             What is a Java package and how is it used?
A             A Java package is a naming context for classes and interfaces. A package is used to create a separate name space for groups of classes and interfaces. Packages are also used to organize related classes and interfaces into a single API unit and to control accessibility to these classes and interfaces.

Q             What are the Object and Class classes used for?
A             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 loaded by a Java program.

Q             What is Serialization and deserialization?
A             Serialization is the process of writing the state of an object to a byte stream.
Deserialization is the process of restoring these objects.

Q             what is tunneling?
A             Tunneling is a route to somewhere. For example, RMI tunneling is a way to make RMI application get through firewall. In CS world, tunneling means a way to transfer data.

Q             Does the code in finally block get executed if there is an exception and a return statement in a catch block?
A             If an exception occurs and there is a return statement in catch block, the finally block is still executed. The finally block will not be executed when the System.exit(1) statement is executed earlier or the system shut down earlier or the memory is used up earlier before the thread goes to finally block.

Q             How you restrict a user to cut and paste from the html page?
A             Using JavaScript to lock keyboard keys. It is one of solutions.

Q             Is Java a super set of JavaScript?
A             No. They are completely different. Some syntax may be similar.

Q             What is a Container in a GUI?
A             A Container contains and arranges other components (including other containers) through the use of layout managers, which use specific layout policies to determine where components should go as a function of the size of the container.

Q             How the object oriented approach helps us keep complexity of software development under control?
A             We can discuss such issue from the following aspects:
Objects allow procedures to be encapsulated with their data to reduce potential interference.
Inheritance allows well-tested procedures to be reused and enables changes to make once and have effect in all relevant places.
The well-defined separations of interface and implementation allow constraints to be imposed on inheriting classes while still allowing the flexibility of overriding and overloading.

Q             What is polymorphism?
A             Polymorphism allows methods to be written that needn't be concerned about the specifics of the objects they will be applied to. That is, the method can be specified at a higher level of abstraction and can be counted on to work even on objects of yet unconceived classes.

Q             What is design by contract?
A             The design by contract specifies the obligations of a method to any other methods that may use its services and also theirs to it. For example, the preconditions specify what the method required to be true when the method is called. Hence making sure that preconditions are. Similarly, post conditions specify what must be true when the method is finished, thus the called method has the responsibility of satisfying the post conditions.
In Java, the exception handling facilities support the use of design by contract, especially in the case of checked exceptions. The assert keyword can be used to make such contracts.

Q             What are use cases?
A             A use case describes a situation that a program might encounter and what behavior the program should exhibit in that circumstance. It is part of the analysis of a program. The collection of use cases should, ideally, anticipate all the standard circumstances and many of the extraordinary circumstances possible so that the program will be robust.