Saturday 30 March 2013

Is it possible to communicate from an applet to servlet and how many ways and how?


Is it possible to communicate from an applet to servlet and how many ways and how?  
Yes, there are three ways to communicate from an applet to servlet and they are: a) HTTP Communication(Text-based and object-based) b) Socket Communication c) RMI Communication

Blog Author: Vijay Kumar


What is session tracking and how do you track a user session in servlets?


What is session tracking and how do you track a user session in servlets?  
Session tracking is a mechanism that servlets use to maintain state about a series requests from the same user across some period of time. The methods used for session tracking are: a) User Authentication occurs when a web server restricts access to some of its resources to only those clients that log in using a recognized username and password. b) Hidden form fields fields are added to an HTML form that are not displayed in the client’s browser. When the form containing the fields is submitted, the fields are sent back to the server. c) URL rewriting every URL that the user clicks on is dynamically modified or rewritten to include extra information. The extra information can be in the form of extra path information, added parameters or some custom, server-specific URL change. d) Cookies a bit of information that is sent by a web server to a browser and which can later be read back from that browser. e) HttpSession- places a limit on the number of sessions that can exist in memory. This limit is set in the session. maxresidents property.


Blog Author: Vijay Kumar


Wednesday 27 March 2013

How many ways can we track client and what are they?


How many ways can we track client and what are they? 
 The servlet API provides two ways to track client state and they are: a) Using Session tracking and b) Using Cookies.



Blog Author: Vijay Kumar

What are the different servers available for developing and deploying Servlets?


What are the different servers available for developing and deploying Servlets?  
a) Java Web Server 
b) JRun 
g) Apache Server 
h) Netscape Information Server
 i) Web Logic

Blog Author: Vijay Kumar


Who is loading the init() method of servlet?


Who is loading the init() method of servlet?  

Web server

Blog Author: Vijay Kumar


What is the life cycle of a servlet?


What is the life cycle of a servlet?  
Each Servlet has the same life cycle: 
a) A server loads and initializes the servlet by init () method. 
b) The servlet handles zero or more client’s requests through service() method. 
c) The server removes the servlet through destroy() method.

Blog Author: Vijay Kumar


What is the difference between doPost and doGet methods?


What is the difference between doPost and doGet methods?  
a) doGet() method is used to get information, while doPost() method is used for posting information. b) doGet() requests can’t send large amount of information and is limited to 240-255 characters. However, doPost()requests passes all of its data, of unlimited length. 
c) A doGet() request is appended to the request URL in a query string and this allows the exchange is visible to the client, whereas a doPost() request passes directly over the socket connection as part of its HTTP request body and the exchange are invisible to the client.

Blog Author: Vijay Kumar


What is the difference between an applet and a servlet?


What is the difference between an applet and a servlet?  
a) Servlets are to servers what applets are to browsers. b) Applets must have graphical user interfaces whereas servlets have no graphical user interfaces.

Blog Author: Vijay Kumar


What is servlet?


What is servlet? 
 Servlets are modules that extend request/response-oriented servers, such as java-enabled web servers. For example, a servlet might be responsible for taking data in an HTML order-entry form and applying the business logic used to update a company’s order database.

Blog Author: Vijay Kumar


How to create and call stored procedures?


How to create and call stored procedures?  
To create stored procedures: Create procedure procedurename (specify in, out and in out parameters) BEGIN Any multiple SQL statement; END; To call stored procedures: CallableStatement csmt = con. prepareCall(”{call procedure name(?,?)}”); csmt. registerOutParameter(column no. , data type); csmt. setInt(column no. , column name) csmt. execute();



Blog Author: Vijay Kumar

What is stored procedure?


What is stored procedure?  
Stored procedure is a group of SQL statements that forms a logical unit and performs a particular task. Stored Procedures are used to encapsulate a set of operations or queries to execute on database. Stored procedures can be compiled and executed with different parameters and results and may have any combination of input/output parameters.

Blog Author: Vijay Kumar


What are the types of statements in JDBC?


What are the types of statements in JDBC?  
Statement: to be used createStatement() method for executing single SQL statement PreparedStatement — To be used preparedStatement() method for executing same SQL statement over and over. CallableStatement — To be used prepareCall() method for multiple SQL statements over and over.

Blog Author: Vijay Kumar


What type of driver did you use in project?


What type of driver did you use in project?  
JDBC-ODBC Bridge driver (is a driver that uses native(C language) libraries and makes calls to an existing ODBC driver to access a database engine).

Blog Author: Vijay Kumar


What are the steps involved for making a connection with a database or how do you connect to a database?


What are the steps involved for making a connection with a database or how do you connect to a database?
a) Loading the driver : To load the driver, Class. forName() method is used. Class. forName(”sun. jdbc. odbc. JdbcOdbcDriver”); When the driver is loaded, it registers itself with the java. sql. DriverManager class as an available database driver. b) Making a connection with database: To open a connection to a given database, DriverManager. getConnection() method is used. Connection con = DriverManager. getConnection (”jdbc:odbc:somedb”, “user”, “password”); c) Executing SQL statements : To execute a SQL query, java. sql. statements class is used. createStatement() method of Connection to obtain a new Statement object. Statement stmt = con. createStatement(); A query that returns data can be executed using the executeQuery() method of Statement. This method executes the statement and returns a java. sql. ResultSet that encapsulates the retrieved data: ResultSet rs = stmt. executeQuery(”SELECT * FROM some table”); d) Process the results : ResultSet returns one row at a time. Next() method of ResultSet object can be called to move to the next row. The getString() and getObject() methods are used for retrieving column values: while(rs. next()) { String event = rs. getString(”event”); Object count = (Integer) rs. getObject(”count”);

Blog Author: Vijay Kumar


Sunday 24 March 2013

What is an event and what are the models available for event handling?


What is an event and what are the models available for event handling?  
An event is an event object that describes a state of change in a source. In other words, event occurs when an action is generated, like pressing button, clicking mouse, selecting a list, etc. There are two types of models for handling events and they are: a) event-inheritance model and b) event-delegation model.

What are the advantages of the model over the event-inheritance model?


What are the advantages of the model over the event-inheritance model?  
The event-delegation model has two advantages over the event-inheritance model. They are: a)It enables event handling by objects other than the ones that generate the events. This allows a clean separation between a component’s design and its use. b)It performs much better in applications where many events are generated. This performance improvement is due to the fact that the event-delegation model does not have to be repeatedly process unhandled events as is the case of the event-inheritance.

What is source and listener?


What is source and listener?  
source : A source is an object that generates an event. This occurs when the internal state of that object changes in some way. listener : A listener is an object that is notified when an event occurs. It has two major requirements. First, it must have been registered with one or more sources to receive notifications about specific types of events. Second, it must implement methods to receive and process these notifications.

What is adapter class?


What is adapter class?  
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 listener by extending one of the adapter classes and implementing only those events in which you are interested. For example, the MouseMotionAdapter class has two methods, mouseDragged()and mouseMoved(). The signatures of these empty are exactly as defined in the MouseMotionListener interface. If you are interested in only mouse drag events, then you could simply extend MouseMotionAdapter and implement mouseDragged() .

Blog Author: Vijay Kumar


What is meant by controls and what are different types of controls in AWT?


What is meant by controls and what are different types of controls in AWT?  
Controls are components that allow a user to interact with your application and the AWT supports the following types of controls: Labels, Push Buttons, Check Boxes, Choice Lists, Lists, Scrollbars, Text Components. These controls are subclasses of Component.

Blog Author: Vijay Kumar


What is the difference between choice and list?


What is the difference between choice and list?  
A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices and only one item may be selected from a choice. A List may be displayed in such a way that several list items are visible and it supports the selection of one or more list items.

Blog Author: Vijay Kumar


What is the difference between set and list?


What is the difference between set and list?  
Set stores elements in an unordered way but does not contain duplicate elements, whereas list stores elements in an ordered way but may contain duplicate elements.

Blog Author: Vijay Kumar


What is an I/O filter?


What is an I/O filter?  
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.

Blog Author: Vijay Kumar


What is serialization and deserialization?


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

Blog Author: Vijay Kumar


What is JDBC?


What is JDBC? 
 JDBC is a set of Java API for executing SQL statements. This API consists of a set of classes and interfaces to enable programs to write pure Java Database applications.

Blog Author: Vijay Kumar


What are drivers available?


What are drivers available?  
a) JDBC-ODBC Bridge driver 
b) Native API Partly-Java driver 
c) JDBC-Net Pure Java driver 
d) Native-Protocol Pure Java driver

Blog Author: Vijay Kumar


What is the difference between JDBC and ODBC?


What is the difference between JDBC and ODBC?  
a) OBDC is for Microsoft and JDBC is for Java applications. b) ODBC can’t be directly used with Java because it uses a C interface. c) ODBC makes use of pointers which have been removed totally from Java. d) ODBC mixes simple and advanced features together and has complex options for simple queries. But JDBC is designed to keep things simple while allowing advanced capabilities when required. e) ODBC requires manual installation of the ODBC driver manager and driver on all client machines. JDBC drivers are written in Java and JDBC code is automatically installable, secure, and portable on all platforms. f) JDBC API is a natural Java interface and is built on ODBC. JDBC retains some of the basic features of ODBC.

Blog Author: Vijay Kumar


What are the types of JDBC Driver Models and explain them?


What are the types of JDBC Driver Models and explain them?  
There are two types of JDBC Driver Models and they are: a) Two tier model and b) Three tier model Two tier model: In this model, Java applications interact directly with the database. A JDBC driver is required to communicate with the particular database management system that is being accessed. SQL statements are sent to the database and the results are given to user. This model is referred to as client/server configuration where user is the client and the machine that has the database is called as the server. Three tier model: A middle tier is introduced in this model. The functions of this model are: a) Collection of SQL statements from the client and handing it over to the database, b) Receiving results from database to the client and c) Maintaining control over accessing and updating of the above.

Blog Author: Vijay Kumar


Thursday 21 March 2013

What is the difference between Array and vector?


What is the difference between Array and vector?  
Array is a set of related data type and static whereas vector is a growable array of objects and dynamic.

Blog Author: Vijay Kumar


What is the difference between exception and error?


What is the difference between exception and error?  
The exception class defines mild error conditions that your program encounters. Exceptions can occur when trying to open the file, which does not exist, the network connection is disrupted, operands being manipulated are out of prescribed ranges, the class file you are interested in loading is missing. The error class defines serious error conditions that you should not attempt to recover from. In most cases it is advisable to let the program terminate when such an error is encountered.

Blog Author: Vijay Kumar


What is multithreading and what are the methods for inter-thread communication and what is the class in which these methods are defined?


What is multithreading and what are the methods for inter-thread communication and what is the class in which these methods are defined?  

Multithreading is the mechanism in which more than one thread run independent of each other within the process. wait (), notify () and notifyAll() methods can be used for inter-thread communication and these methods are in Object class. wait() : When a thread executes a call to wait() method, it surrenders the object lock and enters into a waiting state. notify() or notifyAll() : To remove a thread from the waiting state, some other thread must make a call to notify() or notifyAll() method on the same object.

Blog Author: Vijay Kumar


What is the class and interface in java to create thread and which is the most advantageous method?


What is the class and interface in java to create thread and which is the most advantageous method?  

Thread class and Runnable interface can be used to create threads and using Runnable interface is the most advantageous method to create threads because we need not extend thread class here.



Blog Author: Vijay Kumar

What are the states associated in the thread?


What are the states associated in the thread?  
Thread contains ready, running, waiting and dead states.

Blog Author: Vijay Kumar


When you will synchronize a piece of your code?


When you will synchronize a piece of your code?  
When you expect your code will be accessed by different threads and these threads may change a particular data causing data corruption.

Blog Author: Vijay Kumar


What is deadlock?


What is deadlock?  
When two threads are waiting each other and can’t precede the program is said to be deadlock.

Blog Author: Vijay Kumar


What is daemon thread and which method is used to create the daemon thread?


What is daemon thread and which method is used to create the daemon thread?  
Daemon thread is a low priority thread which runs intermittently in the back ground doing the garbage collection operation for the java runtime system. setDaemon method is used to create a daemon thread.



Blog Author: Vijay Kumar

Are there any global variables in Java, which can be accessed by other part of your program?


Are there any global variables in Java, which can be accessed by other part of your program?  

No, it is not the main method in which you define variables. Global variables is not possible because concept of encapsulation is eliminated here.

Blog Author: Vijay Kumar


What is an applet?


What is an applet?  
Applet is a dynamic and interactive program that runs inside a web page displayed by a java capable browser.

Blog Author: Vijay Kumar


What is the difference between applications and applets?


What is the difference between applications and applets?  
a)Application must be run on local machine whereas applet needs no explicit installation on local machine. b)Application must be run explicitly within a java-compatible virtual machine whereas applet loads and runs itself automatically in a java-enabled browser. d)Application starts execution with its main method whereas applet starts execution with its init method. e)Application can run with or without graphical user interface whereas applet must run within a graphical user interface.


Blog Author: Vijay Kumar


How does applet recognize the height and width?


How does applet recognize the height and width?  
Using getParameters() method.



Blog Author: Vijay Kumar

When do you use codebase in applet?


When do you use codebase in applet?  
When the applet class file is not in the same directory, codebase is used.

Blog Author: Vijay Kumar