Mastek
Mastek
Explanations:
• An Object reference.
• an Object reference
• any interface reference, with casting, with runtime check (except if the class is final
and doesn't implement the interface)
An Interface reference can be converted to:
• an Object reference
• a super-interface reference
• any interface/class reference with casting, with runtime check (except if the class is
final and doesn't implement the interface)
• an Object reference
Explaination :
In addition to Web components, a Web application archive usually contains other files,
including the following:
• Server-side utility classes (database beans, shopping carts, and so on). Often these classes
conform to the JavaBeans component architecture.
• Static Web content (HTML, image, and sound files, and so on).
• Client-side classes (applets and utility classes).
4. J2EE client tier provide support to which of the following client type :
• Web Browser**
• Stand Alone*
• XML Applicable
• Visual Basic
Explaination:
The types of clients in the Client tier of J2EE application programming module are:
• Web Clients – They access HTML or XML content on the Web Tier using HTTP
or HTTPS.
• EJB Clients – They access Enterprise Beans in EJB Server in the EJB tier using
RMI over either IIOP or JRMP.
• EIS Clients – They access database, packaged functionality such as ERP or
Scheduling System and legacy Information System. EIS Clients are use JDBC for
database and either Java Connector or VPP for other EIS-tier resources.
• Web Service Peers – They access data and functionality on the web tier.
Explaination:
JNDI can be implemented over Lightweight Directory Access Protocol (LDAP) and is
useful when locating components (eg, EJBs) in a distributed system.
Java Naming and Directory Services (JNDI) provides a way of connecting to
various kinds of services that are indexed in a registry. JNDI is modeled on LDAP
(Lightweight Directory Access Protocol and usually associated with LDAP. But
importantly, JNDI also forms the backbone of other important APIs, including RMI,
EJB, JMS, and CORBA.
Connection Pooling
Connection pooling is a mechanism whereby when an application closes a connection, that connection is
recycled rather than being destroyed. Because establishing a connection is an expensive operation,
reusing connections can improve performance dramatically by cutting down on the number of new
connections that need to be created.
Assuming that an application wants to connect to a data source represented by the DataSource object
whose logical name is EmployeeDB , the code for getting a connection that uses connection pooling looks
like this:
Just as there is no change in code to get a pooled connection, there is virtually no difference in the code
for using a pooled connection. The only change is that the connection should be closed in a finally block,
which is not a bad idea for closing any type of connection. That way, even if a method throws an
exception, the connection will be closed and put back into the connection pool. The code for the finally
block, which comes after the appropriate try and catch blocks, should look like this:
} finally {
if (con != null) con.close():
}
This finally block ensures that a valid connection will be recycled.
Explaination:
Types of messaging
JMS supports two fundamental messaging mechanisms. The first is point-to-point messaging, in which a
message is sent by one publisher (sender) and received by one subscriber (receiver). The second is publish-
subscribe messaging, in which a message is sent by one or more publishers and received by one or more
subscribers. While these two mechanisms are the actual foundation of JMS, many view the technology in
terms of its three messaging models:
• One-to-one messaging is a point-to-point model. A message is sent from one JMS client
(publisher) to a destination on the server known as a queue. Another JMS client (subscriber) can
access the queue and retrieve the message from the server. Multiple messages may reside on the
queue, but each message is removed upon retrieval.
The structure of a JMS message is fairly intuitive. There is a section for routing, addressing, and message
identification; an optional section where application-specific parameters can be passed; and a third section
where the message payload (text, bytes, value map, object, etc.) is stored. These three sections are known
as the header, property, and body, as illustrated in Figure 1.
The type of messaging model you employ depends upon the needs of your enterprise. It is not uncommon to
employ more than one messaging strategy within a single enterprise. In the sections that follow, we will
explore three JMS solutions for the Java platform: the simple JMS client, session beans combined with JMS,
and message-driven beans. We'll review each type, its pros and cons, and its applicability to different
enterprise scenarios.
Explanation:
Transient is used when u have any sensitive data. Like credit card number, a/c number, etc.
u can also use static variable if u don’t want to serialize the variable.
8. How to compare empty String :
• S.length ==0 *
• S.equals(“”) **
• S = = “”.trim()
• s = " ".trim().intern();
• s==”” *
* All above are correct answers.
Explanation:
I am not sure what kind of Exception you have got. You should post it.
But I would guess it would be NullPointerException.
This exception throws when it found that users is NULL.
You should have
String users = request.getParameter("regional");
Explanation:
JDBC drivers basically communicate via TCP/IP to the DBMS server and pass
SQL statements to it and receive results back from it.
import java.io.LineNumberReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.text.NumberFormat;
import java.util.Locale;
//1st Questions...........
out.flush();
//2nd Questions...........................
NumberFormat nf = NumberFormat.getCurrencyInstance(loc);
double dl = 5676.0;
System.out.println(nf.format(dl));
// 3rd Questions..............................
int i,j,n,m;
i=j=3;
n=2*++i;
m=2*j++;
//System.out.println(n,m,i,j);
System.out.println(""+n+""+m+""+i+""+j);
//5th Questions...........
int num1=1;
float num2=num1/2f;
//Output : 0.5
}