1. What do You understand by the word FINAL ?
To ensure SECURITY i.e. no object can subclass the final class. If u r content with your class/ method and want no other class to subclass or change this final class. eg. java.lang.String.2. Difference between Abstract Class and Interface
An interface cannot implement any methods, whereas an abstract class can. A class can implement many interfaces but can have only one superclass. An interface is not part of the class hierarchy. Unrelated classes can implement the same interface. eg java.lang.Number(an abstract class)3. HTTP Status Codes
Some commonly used status codes include:4. What is user defined exception?
To create our own exception types to handle situations specific to our applications. This is quite easy to do just define a subclass of Exception (which is, of course, a subclass of Throwable). Your subclasses don't need to actually implement anything-it is their existence in the type system that allows you to use them as exceptions.5. What do you know about the garbage collector?
Java's garbage collector runs periodically to recycle unused objects. However, sometimes you will want to collect discarded objects prior to the collector's next appointed rounds. You can run the garbage collector on demand by calling the gc( ) method.6. What is the difference between java and c++?
7. In an HTML form I have a button which makes us to open another page in 15 seconds. How will you do that?
8. What is the difference between process and threads?
A thread--sometimes called an execution context or a lightweight process--is a single sequential flow of control within a program. You use threads to isolate tasks. Each thread runs independently from the others, but at the same time. A process is also a sequential flow of control within a program running independently from others, but not at the same time.9. When is update method called?
An update method is essentially used to update data of a database table. stmt.executeUpdate(updateString); Executes the given SQL statement, which may be an INSERT, UPDATE, or DELETE statement or an SQL statement that returns nothing, such as an SQL DDL statement.10. Have you ever used HashTable and Dictionary?
Yes. A Hashtable, maps keys to values. Any non-null object can be used as a key or as a value. To successfully store and retrieve objects from a Hashtable, the objects used as keys must implement the hashCode method and the equals method. The Dictionary class is the abstract parent of any class, such as Hashtable, which maps keys to values. Every key and every value is an object. In any one Dictionary object, every key is associated with at most one value. (By the way HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and permits nulls.)11. What are statements in Java?
A statement forms a complete unit of execution. Any expression can be made into a statement by terminating the expression with a semicolon (;)12. What is a JAR file?
JAR stands for Java Archive. Using jar tool it is possible to assemble a number of different J2EE applications which use some of the same components. No extra coding is needed; it is only a matter of assembling (or packaging) various J2EE modules into J2EE JAR files. Various forms of JAR files are .ear [Enterprise Archive], .war [Web Archive], .rar [Resource Adapter Archive].13. What is JNI?
JNI - Java Native Interface allows Java code that runs within a Java Virtual Machine (JVM) to operate with applications and libraries written in other languages, such as C, C++, and assembly. In addition, the Invocation API allows you to embed the Java Virtual Machine into your native applications. Programmers use the JNI to write native methods to handle those situations when an application cannot be written entirely in the Java programming language.14. What is the base class for all swing components?
JComponent is the base class for all Swing components except top-level containers. To use a component that inherits from JComponent, you must place the component in a containment hierarchy whose root is a top-level Swing container. Top-level Swing containers -- such as JFrame, JDialog, and JApplet -- are specialized components that provide a place for other Swing components to paint themselves.15. What is JFC?
JFC - Java Foundation Classes encompass a group of features for building graphical user interfaces (GUIs) and adding rich graphics functionality and interactivity to Java applications. Few of JFC features are Swing GUI Components, Pluggable Look-and-Feel Support, Drag-and-Drop Support, Internationalization, Accessibility API and Java 2D API.16. What is the difference between AWT and Swing?
17. Considering notepad/IE or any other thing as process, what will happen if you start notepad or IE 3 times? Whether three processes are started or three threads are started?
3 threads are started. As opening a notepad/IE is a process which means, presenting the user with all the components and tools open for their respective functionalities. Since running the same process 3 times leads to creating 3 different threads all of which are available for performing different functionality simultaneously or at the same time.18. How does thread synchronization occur in a monitor?
A monitor is chunk of data that can only be accessed through a set of routines. This type of encapsulation is expressed as an object in today's terminology, although monitors were designed like modules rather than instances of a class. A monitor's access routines are guaranteed to execute in a mutually exclusive manner. Java relaxes this constraint slightly to allow a class' methods to be explicitly specified as synchronized, which always execute to completion. One can say that a monitor access routine acquires a lock on that monitor, which it releases upon returning from that method. In this way, mutual exclusion is implicitly achieved. Only synchronized Java methods acquire a lock on an object. A call to wait() releases the lock, but will reacquire it as it is awakened by a notifyAll(). notifyAll() does not yield execution nor release its hold on an object's lock. The only way to release a lock is by waiting or returning from a synchronized method.19. Is there any tag in HTML to upload and download files?
20. Why do you canvas?
A Canvas component represents a blank rectangular area of the screen onto which the application can draw or from which the application can trap input events from the user. An application must subclass the Canvas class in order to get useful functionality such as creating a custom component. The paint method must be overridden in order to perform custom graphics on the canvas.21. How can you know about drivers and database information?
The javax.sql package provides:22. What is serialization?
Java's object serialization allows you to take any object that implements the Serializable interface and turn it into a sequence of bytes that can later be fully restored to regenerate the original object. This is even true across a network, which means that the serialization mechanism automatically compensates for differences in operating systems. That is, you can create an object on a Windows machine, serialize it, and send it across the network to a Unix machine where it will be correctly reconstructed.23. Can you load the server object dynamically? If so what are the 3 major steps involved in it?
Yes, through a Dynamic Proxy. The purpose of a Dynamic proxy is to be able to act as a universal proxy for several class implementations without knowing the actual class until runtime. 1.24. What is the layout for toolbar?
Border Layout - With most look and feels, the user can drag out a tool bar into a separate window (unless the floatable property is set to false). For drag-out to work correctly, it is recommended that you add JToolBar instances to one of the four "sides" of a container whose layout manager is a BorderLayout, and do not add children to any of the other four "sides"25. What is the difference between Grid and Gridbaglayout?
The GridLayout class is a layout manager that lays out a container's components in a rectangular grid. The container is divided into equal-sized rectangles, and one component is placed in each rectangle. The GridBagLayout class is a flexible layout manager that aligns components vertically and horizontally, without requiring that the components be of the same size. Each component managed by a GridBagLayout is associated with an instance of GridBagConstraints. The constraints object specifies where a component's display area should be located on the grid and how the component should be positioned within its display area.26. How will you add panel to a frame?
jfrm.getContentPane().add(pnl); Get access to the content pane(container) of the JFrame(jfrm) and then add the Jpanel(pnl) component to this container.27. Where are the card layouts used?
A CardLayout object is a layout manager for a container. It treats each component in the container as a card. Only one card is visible at a time, and the container acts as a stack of cards. The first component added to a CardLayout object is the visible component when the container is first displayed.28. What is the corresponding layout for card in swing?
OverlayLayout - A layout manager to arrange components over the top of each other. The requested size of the container will be the largest requested size of the children, taking alignment needs into consideration. The alignment is based upon what is needed to properly fit the children in the allocation area. The children will be placed such that their alignment points are all on top of each other.29. What is light weight component?
javax.swing provides a set of "lightweight" (all-Java language) components that, to the maximum degree possible, work the same on all platforms. Swing is fully written in java and its capabilities are not tied to local platform (lightweight)30. What are the benefits of Swing over AWT?
31. How can two threads be made to communicate with each other?
Thread synchronization is achieved using the notifyAll() and wait() methods. The wait() method relinquishes the lock held by the Consumer on the resource and then waits for notification from the Producer. When the producer is done with the resource it calls the notifyAll() method to intimate all the threads waiting for this resource. [wait(long timeout) vs sleep(long timeout) Both wait() and sleep() delay for the requested amount of time, but you can easily wake up wait() with a notify but a sleeping thread cannot be awakened prematurely.]32. What are the files generated after using IDL to java compiler?
When Hello.idl is given to the idlj compiler, following files are generated:33. What is the protocol used by server and client?
In the context of RMI we use TCP/IP. TCP/IP provides a persistent, stream-based connection between two machines based on an IP address and port number at each end. Usually a DNS name is used instead of an IP address.34. What is the functionality of stubs and skeletons?
The stub class plays the role of the proxy, and is responsible for forwarding all the calls from client program to the remote server. A skeleton is a helper class that is generated for RMI to use. The skeleton understands how to communicate with the stub across the RMI link. The skeleton carries on a conversation with the stub; it reads the parameters for the method call from the link, makes the call to the remote service implementation object, accepts the return value, and then writes the return value back to the stub.35. What is the mapping mechanism used by java to identify IDL language?
The tool idlj reads OMG IDL files and creates the required Java files. The idlj compiler defaults to generating only the client-side bindings. If you need both client-side bindings and server-side skeletons, you must use the -fall option when running the idlj compiler. Eg: idlj -fall Hello.idl module HelloApp - package HelloApp; interface Hello - interface Hello;36. What is serializable interface?
Serializability of a class is enabled by the class implementing the java.io.Serializable interface. Classes that do not implement this interface will not have any of their state serialized or deserialized. All subtypes of a serializable class are themselves serializable. The serialization interface has no methods or fields and serves only to identify the semantics of being serializable. Classes that require special handling during the serialization and deserialization process must implement special methods with these exact signatures: private void writeObject(java.io.ObjectOutputStream out) throws IOException private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException; The writeObject() method is responsible for writing the state of the object for its particular class so that the corresponding readObject method can restore it. The default mechanism for saving the Object's fields can be invoked by calling out.defaultWriteObject. The readObject() method is responsible for reading from the stream and restoring the classes fields. It may call in.defaultReadObject to invoke the default mechanism for restoring the object's non-static and non-transient fields. The defaultReadObject method uses information in the stream to assign the fields of the object saved in the stream with the correspondingly named fields in the current object.37. What is the use of interface?
Using interface, you can specify a set of methods which can be implemented by one or more classes. The interface, itself, does not actually define any implementation. Interfaces are designed to support dynamic method resolution at run time. Normally, in order for a method to be called from one class to another, both classes need to be present at compile time so the Java compiler can check to ensure that the method signatures are compatible. This requirement by itself makes for a static and nonextensible classing environment. Inevitably in a system like this, functionality gets pushed up higher and higher in the class hierarchy so that the mechanisms will be available to more and more subclasses. Interfaces are designed to avoid this problem. They disconnect the definition of a method or set of methods from the inheritance hierarchy. Since interfaces are in a different hierarchy from classes, it is possible for classes that are unrelated in terms of the class hierarchy to implement the same interface. This is where the real power of interfaces is realized.38. Why java is not fully objective oriented?
It does not support multiple inheritance.39. Why does java not support multiple inheritance?
Interfaces add most of the functionality that is required for many applications which would normally resort to using multiple inheritance in a language such as C++. By not allowing the inheritance of multiple base classes by a single subclass, Java greatly simplifies the inheritance model. Multiple inheritance carries with it several special cases that must be handled. This adds overhead to both the compiler and the run-time system, while providing only marginal benefit for the programmer.40. What is the root class for all java classes?
java.lang.Object class is the root of the class hierarchy. Every class has Object as a superclass. All objects, including arrays, implement the methods of this class. java.lang provides classes that are fundamental to the design of the Java programming language. The most important classes are Object, which is the root of the class hierarchy, and Class, instances of which represent classes at run time.41. What is polymorphism?
Polymorphism is a feature that allows one interface to be used for a general class of actions. The specific action is determined by the exact nature of the situation. The concept of polymorphism is often expressed by the phrase "one interface, multiple methods" This means that it is possible to design a generic interface to a group of related activities. This helps reduce complexity by allowing the same interface to be used to specify a general class of action. It is the compiler's job to select the specific action (that is, method) as it applies to each situation.42. What are virtual functions?
Virtual functions facilitate dynamic binding of functions to the appropriate objects. They are the means by which functions of the base class can be overridden by functions of the derived class. Virtual functions allow derived class to redefine member functions inherited from the base class. General programs can then be written that are obvious to the classes of the objects they manipulate, through dynamic binding. The runtime system will choose the function appropriate to a particular class.43. What are session variable in servlets?
Maintaining and associating the state between the series of requests from a client can be called a session. Because there is no way for an HTTP client to signal that it no longer needs a session, each session has an associated timeout so that its resources can be reclaimed. Sessions are represented by an HttpSession object. You access a session by calling the getSession() method of a request object. This method returns the current session associated with this request, or, if the request does not have a session, it creates one. Now this SID is attached to response in scope that when the client comes with another request it comes with this SID. A web container can use several methods to associate a session with a user, all of which involve passing an identifier between the client and the server. The identifier can be maintained on the client as a cookie, or the web component can include the identifier in every URL that is returned to the client (URL rewriting).44. What is client server computing?
Client/server computing provides the capability to use the most cost-effective user interface, data storage, sharing resources among diverse platforms, connectivity, data sharing and integrate application services. It provides the means to integrate personal productivity applications for an individual employee or manager with specific business data processing needs to satisfy total information processing requirements for the entire enterprise.45. What is constructor and virtual function? Can we call a virtual function a constructor?
A Constructor is a special member function whose main function is to allocate the required resources such as memory and initialize the objects of its class. A constructor is distinct from other member functions of the class, and it has the same name as its class. It is executed automatically when a class is instantiated. Constructors can be overloaded. Virtual functions facilitate dynamic binding of functions to the appropriate objects A virtual function declared in the base class can be overridden in the derived class. We cannot call a virtual function a constructor because we cannot override constructors unlike a virtual function.46. Why do we use oops concepts? What is its advantage?
Object-oriented programming organizes a program around its data (that is, objects) and a set of well-defined interfaces to that data. An object-oriented program can be characterized as data controlling access to code. To be truly considered "object oriented", a programming language should support at a minimum four characteristics:47. What is middleware? What is the functionality of web server?
Middle Tier is a functional component sitting in between a data consumer and a data server to perform the crucial tasks of application development and deployment-from integrating enterprise systems and databases to delivering services and collaborating over the Internet. A typical Web Server provides all of the essential core functions and services, such as:48. What is the exact difference in between Unicast and Multicast object? Where will it be used?
RMI provides only one way for clients to connect to remote service implementations: a unicast, point-to-point connection. Before a client can use a remote service, the remote service must be instantiated on the server and exported to the RMI system. With multicast, a single proxy could send a method request to multiple implementations simultaneously and accept the first reply (this improves response time and possibly improves availability).49. What is the main functionality of the remote reference layer?
RRL understands how to interpret and manage references made from clients to the remote service objects. It connects clients to remote service objects that are running and exported on a server. RMI supports activatable remote objects. When a method call is made to the proxy for an activatable object, RMI determines if the remote service implementation object is dormant. If it is dormant, RMI will instantiate the object and restore its state from a disk file. Once an activatable object is in memory, it behaves just like usual remote service implementation objects. (also called Lazy Activation)50. What is the main functionality of Prepared Statement?
If you want to execute a Statement object many times, it will normally reduce execution time to use a PreparedStatement object instead. The main feature of a PreparedStatement object is that, unlike a Statement object, it is given an SQL statement when it is created. The advantage to this is that in most cases, this SQL statement will be sent to the DBMS right away, where it will be compiled. As a result, the PreparedStatement object contains not just an SQL statement, but an SQL statement that has been precompiled. This means that when the PreparedStatement is executed, the DBMS can just run the PreparedStatement 's SQL statement without having to compile it first.51. What is meant by Static query and Dynamic query?
Any SQL statement whose where clause values are specified prior to the execution of the application is called an Static Query. Ex: Prepared Statements. An SQL statement built up at runtime, i.e. values to the query are passed while the application is running, is a Dynamic Query. Ex: Inputs can be taken based on user selecting elements of a FORM.52. What are Normalization Rules? Define Normalization?
The process of separating data into distinct, unique sets is called normalization. This is implemented to improve the performance of the RDBMS, such as reduces redundancy of data and data inconsistency.53. What is meant by Servlet? What are the parameters of service method?
A servlet is a Java programming language class that is used to extend the capabilities of servers that host applications access via a request-response programming model. Although servlets can respond to any type of request, they are commonly used to extend the applications hosted by web servers. For such applications, Java Servlet technology defines HTTP-specific servlet classes.54. What is meant by Session? Explain something about HTTP Session Class?
Because HTTP is a request-response protocol, a session is considered new until the client joins it. Join means that the client returns session tracking information to the server, indicating that a session has been established. Until the client joins a session, you cannot assume that the next client response is part of the current session. Maintaining and associating the state between the series of requests from a client can be called a session. Because there is no way for an HTTP client to signal that it no longer needs a session, each session has an associated timeout so that its resources can be reclaimed.55. In a container there are 5 components. I want to display all the component names, how will you do that?
public abstract Enumeration getServletNames() This method of javax.servlet.ServletContext interface returns an enumeration of the Servlet object names in this server. Only servlets that are accessible (i.e., from the same namespace) will be returned. The enumeration always includes the servlet itself. This is a dangerous method to call for the following reasons.56. Tell some latest versions in JAVA related areas?
Java Platform, Standard Edition version 6, code-named Mustang, provides a solution that allows the application to show the splash screen much earlier, even before the virtual machine starts. Now, a Java application launcher is able to decode an image and display it in a simple nondecorated window. Use of an option in the manifest file can allow a JAR-packaged application to display a splash screen. Other types of applications can use a command-line option. You can use a desktop shortcut or a script to provide the command-line option to the Java application launcher. The splash screen can display any GIF, PNG, or JPEG image, with transparency, translucency, and animation.57. What is meant by class loader? How many types are there? When will we use them?
java.lang.ClassLoader A class loader is an object that is responsible for loading classes. The class ClassLoader is an abstract class. Given the name of a class, a class loader should attempt to locate or generate data that constitutes a definition for the class. A typical strategy is to transform the name into a file name and then read a "class file" of that name from a file system. Every Class object contains a reference to the ClassLoader that defined it.58. What is meant by flickering?
Flickering is an inconstant or wavering light, sometimes appears on the screen. Most displays have an ideal refresh rate (also called a vertical scan frequency) of about 70 hertz (Hz), meaning that the screen is refreshed 70 times a second. Low refresh rates cause the screen to flicker, contributing to eye strain. The higher the refresh rate, the better for your eyes.59. What is meant by distributed application? Why are we using that in our application?
A distributed application is one whose application logic is divided into components according to function, and the various application components that make up an application are installed on different machines depending on the tier in the multitiered environment to which the application component belongs.60. Explain 2-tier and 3-tier architecture?
2-tier architecture specifies a framework wherein information is exchanged between only two computers namely the server and the client. Typically in a 2-tier environment one computer is a consumer requesting information from another computer acting as producer. 3-tier architecture specifies an extra intermediary layer called the middleware layer, in addition to the 2-tier layers. The logical part of a typical application is separated from the client and usually is at the middle tier. Middle ware acts on behalf of the end server by accepting the client requests, processing the requests, constructing the response and sending back the response to the client. 3-tier architecture is also referred to as a Distributed Computing Environment.61. What is meant by cookies? Explain the main features?
Cookies are used to store application-specific information at the client. Sometimes cookies are used to maintain an identifier for tracking a user's session. Browsers usually store the last visited Web Page into a hidden private memory location because if the browser has a request to the last visited page, at a later time, firstly it searches the cookies for this URL and if found one, gets back the information without actually connecting to the server.62. Why java is considered as platform independent?
The key that allows Java to solve both the security and the portability problems is that the output of a Java compiler is not executable code. Rather, it is bytecode. Bytecode is a highly optimized set of instructions designed to be executed by the Java run-time system, which is called the Java Virtual Machine (JVM). That is, in its standard form, the JVM is an interpreter for bytecode. Translating a Java program into bytecode helps makes it much easier to run a program in a wide variety of environments. The reason is straightforward: only the JVM needs to be implemented for each platform. Once the run-time package exists for a given system, any Java program can run on it thus making java platform independent.63. What are the advantages of java over C++?
64. How java can be connected to a database?
JDBC provides the API for accessing and processing data stored in a data source (usually a relational database) using the Java programming language. This API includes a framework whereby different drivers can be installed dynamically to access different data sources. Although the JDBC API is mainly geared to passing SQL statements to a database, it provides for reading and writing data from any data source with a tabular format.65. What are abstract classes?
To model an abstract concept without being able to create an instance of it, we generally use an abstract class. An abstract class is a class that can only be subclassed-- it cannot be instantiated. We use the abstract key word to declare the abstract class.66. What is an interface?
An interface defines a protocol of behavior that can be implemented by any class anywhere in the class hierarchy. An interface defines a set of methods but does not implement them. A class that implements the interface agrees to implement all the methods defined in the interface, thereby agreeing to certain behavior.67. What are adapter classes?
An adapter class provides an empty implementation of all methods in an event listener interface. Adapter classes are useful when you want to receive and process only some of the events that are handled by a particular event listener interface. You can define a new class to act as an event listener by extending one of the adapter classes and implementing only those events in which you are interested.68. what is meant wrapper classes?
Java uses simple types, such as int and char, for performance reasons. These data types are not part of the object hierarchy. They are passed by value to methods and cannot be directly passed by reference. Also, there is no way for two methods to refer to the same instance of an int. At times, you will need to create an object representation for one of these simple data types. To address this need, Java provides classes that correspond to each of the simple types. In essence, these classes encapsulate, or wrap, the simple types within a class. Thus, they are commonly referred to as type wrappers. The abstract class Number defines a superclass that is implemented by the classes that wrap the numeric types byte, short, int, long, float, and double. Number has abstract methods that return the value of the object in each of the different number formats. That is, doubleValue( ) returns the value as a double, floatValue( ) returns the value as a float, and so on.69. What are JVM, JRE, J2EE, JIT and JNI?
70. What are swing components?
The part of a Swing GUI application through which user interacts is called a component. Swing components can be Buttons, Labels, Textboxes, Panels, Frames, Trees, Panes, Toolbars, etc.71. What do you mean by light weight and heavy weight components?
72. What is meant by function overloading and function overriding?
Function Overloading is the process of declaring a function more than once with same name but with different signatures or parameters. The methods can be from the same class or inherited. Function Overriding is the process of defining a function more than once with same name but with different definitions. Usually the methods derived from base class are overridden.73. What do you mean by multithreading?
A multithreaded program contains two or more modules that can run concurrently. Each part of such a program is called a thread, and each thread defines a separate path of execution. Thus, multithreading is a specialized form of multitasking74. What are byte codes?
Bytecode is a highly optimized set of instructions designed to be executed by the Java run-time system, which is called the Java Virtual Machine (JVM).75. What are streams?
A stream is an abstraction that either produces or consumes information. A stream is linked to a physical device by the Java I/O system. An input stream can abstract many different kinds of input: from a disk file, a keyboard, or a network socket. Likewise, an output stream may refer to the console, a disk file, or a network connection. Streams are clean ways to deal with input/output without having every part of your code understand the difference between a keyboard and a network, for example. Java implements streams within class hierarchies defined in the java.io package.