Wednesday, February 7, 2007

Which method is used to output a string to an applet? Which function is this method included in?

drawString( ) method is used to output a string to an applet. This method is included in the paint method of the Applet.


SOURCE : www.referjava.com

What are the steps involved in Applet development?

Following are the steps involved in Applet development:
o Create/Edit a Java source file. This file must contain a class which extends Applet class.
o Compile your program using javac
o Execute the appletviewer, specifying the name of your applet’s source file or html file. In case the applet information is stored in html file then Applet can be invoked using java enabled web browser.


SOURCE : www.referjava.com

What are the Applet’s information methods?

The following are the Applet’s information methods: getAppletInfo() method: Returns a string describing the applet, its author, copyright information, etc. getParameterInfo( ) method: Returns an array of string describing the applet’s parameters.


SOURCE : www.referjava.com

What is AppletStub Interface?

The applet stub interface provides the means by which an applet and the browser communicate. Your code will not typically implement this interface.


SOURCE : www.referjava.com

Which classes and interfaces does Applet class consist?

Applet class consists of a single class, the Applet class and three interfaces: AppletContext, AppletStub, and AudioClip.

SOURCE : www.referjava.com

How do I determine the width and height of my application?

Use the getSize() method, which the Applet class inherits from the Component class in the Java.awt package. The getSize() method returns the size of the applet as a Dimension object, from which you extract separate width, height fields. The following code snippet explains this:
Dimension dim = getSize();
int appletwidth = dim.width();
int appletheight = dim.height();


SOURCE : www.referjava.com

Can applets on different pages communicate with each other?

No, Not Directly. The applets will exchange the information at one meeting place either on the local file system or at remote system.


SOURCE : www.referjava.com

How do I select a URL from my Applet and send the browser to that page?

Ask the applet for its applet context and invoke showDocument() on that context object.
URL targetURL;
String URLString
AppletContext context = getAppletContext();
try
{
targetURL = new URL(URLString);
}
catch (MalformedURLException e)
{
// Code for recover from the exception
}
context. showDocument (targetURL);


SOURCE : www.referjava.com

How can I arrange for different applets on a web page to communicate with each other?

Name your applets inside the Applet tag and invoke AppletContext’s getApplet() method in your applet code to obtain references to the
other applets on the page.

SOURCE : www.referjava.com

How do we read number information from my applet’s parameters, given that Applet’s getParameter() method returns a string?

Use the parseInt() method in the Integer Class, the Float(String) constructor or parseFloat() method in the Class Float, or the
Double(String) constructor or parseDoulbl() method in the class Double.

SOURCE : www.referjava.com

Can we pass parameters to an applet from HTML page ? How?

We can pass parameters to an applet using tag in the following way:
o
o
Access those parameters inside the applet is done by calling getParameter() method inside the applet. Note that getParameter() method returns String value corresponding to the parameter name.

SOURCE : www.referjava.com

What are the practical benefits, if any, of importing a specific class rather than an entire package (e.g. import java.net.* versus import java.net.So

It makes no difference in the generated class files since only the classes that are actually used are referenced by the generated class file. There is another practical benefit to importing single classes, and this arises when two (or more) packages have classes with the same name. Take java.util.Timer and javax.swing.Timer, for example. If I import java.util.* and javax.swing.* and then try to use “Timer", I get an error while compiling (the class name is ambiguous between both packages). Let’s say what you really wanted was the javax.swing.Timer class, and the only classes you plan on using in java.util are Collection and HashMap. In this case, some people will prefer to import java.util.Collection and import java.util.HashMap instead of importing java.util.*. This will now allow them to use Timer, Collection, HashMap, and other javax.swing classes without using fully qualified class names in.


SOURCE : www.referjava.com

How many methods do u implement if implement the Serializable Interface?

The Serializable interface is just a “marker” interface, with no methods of its own to implement. Other ‘marker’ interfaces are
1. java.rmi.Remote
2. java.util.EventListener


SOURCE : www.referjava.com

What is passed by ref and what by value?

All Java method arguments are passed by value. However, Java does manipulate objects by reference, and all object variables themselves are references.


SOURCE : www.referjava.com

What is constructor chaining and how is it achieved in Java?

A child object constructor always first needs to construct its parent (which in turn calls its parent constructor.). In Java it is done via an implicit call to the no-args constructor as the first statement.


SOURCE : www.referjava.com

What is hash-collision in Hashtable and how it is handled in Java?

Two different keys with the same hash value. Two different entries will be kept in a single hash bucket to avoid the collision.

SOURCE : www.referjava.com

What is the difference between instanceof and isInstance?

Instanceof is used to check to see if an object can be cast into a specified type without throwing a cast class exception. isInstance() Determines if the specified Object is assignment-compatible with the object represented by this Class. This method is the dynamic equivalent of the Java language instanceof operator. The method returns true if the specified Object argument is non-null and can be cast to the reference type represented by this Class object without raising a ClassCastException. It returns false otherwise.


SOURCE : www.referjava.com

Why does it take so much time to access an Applet having Swing Components the first time?

Because behind every swing component are many Java objects and resources. This takes time to create them in memory. JDK 1.3 from Sun has some improvements which may lead to faster execution of Swing applications.


SOURCE : www.referjava.com

How do I include static files within a JSP page?

Static resources should always be included using the JSP include directive. This way, the inclusion is performed just once during the translation phase. The following example shows the syntax: Do note that you should always supply a relative URL for the file attribute. Although you can also include static resources using the action, this is not advisable as the inclusion is then performed for each and every request.


SOURCE : www.referjava.com

How can I implement a thread-safe JSP page?

You can make your JSPs thread-safe by having them implement the SingleThreadModel interface. This is done by adding the directive <%@ page isThreadSafe="false" % > within your JSP page.


SOURCE : www.referjava.com

What is SOAP and how does it relate to XML?

The Simple Object Access Protocol (SOAP) uses XML to define a protocol for the exchange of information in distributed computing environments. SOAP consists of three components: an envelope, a set of encoding rules, and a convention for representing remote procedure calls. Unless experience with SOAP is a direct requirement for the open position, knowing the specifics of the protocol, or how it can be used in conjunction with HTTP, is not as important as identifying it as a natural application of XML.


SOURCE : www.referjava.com

What is DOM and how does it relate to XML?

The Document Object Model (DOM) is an interface specification maintained by the W3C DOM Workgroup that defines an application independent mechanism to access, parse, or update XML data. In simple terms it is a hierarchical model that allows developers to manipulate XML documents easily

SOURCE : www.referjava.com

What is Isolation Level?

An isolation level determines the degree of isolation of data between concurrent transactions. The default SQL Server isolation level is Read Committed. A lower isolation level increases concurrency, but at the expense of data correctness. Conversely, a higher isolation level ensures that data is correct, but can affect concurrency negatively. The isolation level required by an application determines the locking behavior SQL Server uses. SQL-92 defines the following isolation levels, all of which are supported by SQL Server:

Read uncommitted (the lowest level where transactions are isolated only enough to ensure that physically corrupt data is not read).
Read committed (SQL Server default level).
Repeatable read.
Serializable (the highest level, where transactions are completely isolated from one another).


SOURCE : www.referjava.com

What are defaults? Is there a column to which a default can't be bound?

A default is a value that will be used by a column, if no value is supplied to that column while inserting data. IDENTITY columns and timestamp columns can't have defaults bound to them.

SOURCE : www.referjava.com

What is Transaction?

A transaction is a sequence of operations performed as a single logical unit of work. A logical unit of work must exhibit four properties, called the ACID (Atomicity, Consistency, Isolation, and Durability) properties, to qualify as a transaction.

SOURCE : www.referjava.com

What are the constraints ?

Table Constraints define rules regarding the values allowed in columns and are the standard mechanism for enforcing integrity. SQL Server 2000 supports five classes of constraints. NOT NULL , CHECK, UNIQUE, PRIMARY KEY, FOREIGN KEY.

SOURCE : www.referjava.com

What is the purpose of UPDATE STATISTICS?

Updates information about the distribution of key values for one or more statistics groups (collections) in the specified table or indexed view.

SOURCE : www.referjava.com

How can I enforce to use particular index?

You can use index hint (index=index_name) after the table name. SELECT au_lname FROM authors (index=aunmind).

SOURCE : www.referjava.com

What is session hijacking?

If you application is not very secure then it is possible to get the access of system after acquiring or generating the authentication information. Session hijacking refers to the act of taking control of a user session after successfully obtaining or generating an authentication session ID. It involves an attacker using captured, brute forced or reverse-engineered session IDs to get a control of a legitimate user's Web application session while that session is still in progress.

SOURCE : www.referjava.com

What information that the ServletResponse interface gives the servlet methods for replying to the client?

It Allows the servlet to set the content length and MIME type of the reply.
Provides an output stream, ServletOutputStream and a Writer through which the servlet can send the reply data.

SOURCE : www.referjava.com

What information that the ServletRequest interface allows the servlet access to?

Information such as the names of the parameters passed in by the client, the protocol (scheme) being used by the client, and the names of the remote host that made the request and the server that received it.

The input stream, ServletInputStream.Servlets use the input stream to get data from clients that use application protocols such as the HTTP POST and PUT methods.

www.referjava.com

When a servlet accepts a call from a client, it receives two objects- What are they?

ServeltRequest: Which encapsulates the communication from the client to the server.

ServletResponse: Which encapsulates the communication from the servlet back to the client.

ServletRequest and ServletResponse are interfaces defined by the javax.servlet package.

SOURCE : www.referjava.com