Industrial Training

Tcs Core Java Campus Interview Question Answer


What are the advantages of using exception handling?

Exception handling provides the following advantages over "traditional" error management techniques:

* Separating Error Handling Code from "Regular" Code.

* Propagating Errors Up the Call Stack.

* Grouping Error Types and Error Differentiation.


What is transient variable?

Transient variable can't be serialize. For example if a variable is declared as transient in a Serializable class and the class is written to an ObjectStream, the value of the variable can't be written to the stream instead when the class is retrieved from the ObjectStream the value of the variable becomes null.


What are Access Specifiers available in Java?

Access specifiers are keywords that determines the type of access to the member of a class. These are:

1.Public

2.Protected

3.Private

4.Defaults


Explain the Encapsulation principle.

Encapsulation is a process of binding or wrapping the data and the codes that operates on the data into a single entity. This keeps the data safe from outside interface and misuse. One way to think about encapsulation is as a protective wrapper that prevents code and data from being arbitrarily accessed by other code defined outside the wrapper.


How are notifications made when a server is added to a cluster?

The Web Logic Server cluster broadcasts the availability of a new server instance each time a new instance joins the cluster. Cluster-aware stubs also periodically update their list of available server instances.


What is an Applet? Should applets have constructors?

Applets are small programs transferred through Internet, automatically installed and run as part of web-browser. Applets implements functionality of a client. Applet is a dynamic and interactive program that runs inside a Web page displayed by a Java-capable browser. We don?t have the concept of Constructors in Applets. Applets can be invoked either through browser or through Appletviewer utility provided by JDK.


What is the life cycle of an applet?

init( ) method - called when an applet is first loaded start( ) method - called each time an applet is started paint( ) method - called when the applet is minimized or maximized stop( ) method - called when the browser moves off the applet's page destroy( ) method - called when the browser is finished with the applet


How do clients handle DNS requests to failed servers?

If a server fails and DNS continues to send requests to the unavailable machine, this can waste bandwidth. For a Java client application, this problem occurs only during startup. WebLogic Server caches the DNS entries and removes the unavailable ones, to prevent the client from accessing a failed server twice. Failed servers can be more of a problem for browser-based clients, because they always use DNS. To avoid unnecessary DNS requests with browser-based clients, use a third-party load-balancer such as Resonate, BigIP, Alteon, and LocalDirector. These products mask multiple DNS addresses as a single address. They also provide more sophisticated load-balancing options than round-robin, and they keep track of failed servers to avoid routing unnecessary requests.


How does a server know when another server is unavailable?

Web Logic Server uses two mechanisms to determine if a given server instance is unavailable. Each Web Logic Server instance in a cluster uses multicast to broadcast regular "heartbeat" messages that advertise its availability. By monitoring heartbeat messages, server instances in a cluster determine when a server instance has failed. The other server instances will drop a server instance from the cluster, if they do not receive three consecutive heartbeats from that server instance Web Logic Server also monitors socket errors to determine the availability of a server instance. For example, if server instance A has an open socket to server instance B, and the socket unexpectedly closes, server A assumes that server B is offline.


Why doesn't my browser applet connect to the database?

Problem: I'm using a WebLogic multitier driver in an applet as an interface to a DBMS. If I run the class using the Sun Appletviewer on my local machine, I have no problems. But when I try to run the applet in a Netscape browser, it will not connect.

A. If Appletviewer works and Netscape does not, it is an indication that you are violating a Netscape security restriction. In this case, the violation is that an applet cannot open a socket to a machine other than the one from which it loaded the applet. To solve this problem, you will have to serve your applet code from the same machine that hosts the DBMS.

In addition, the IP naming format you use in the applet CODEBASE and the constructor for the T3Client must match. That is, you can't use dot-notation in one place and a domain name in the other.


What are the Applet?s Life Cycle methods? Explain them? - Following are methods in the life cycle of an Applet

• init() method - called when an applet is first loaded. This method is called only once in the entire cycle of an applet. This method usually intialize the variables to be used in the applet.

  *start( ) method - called each time an applet is started.

  * paint() method - called when the applet is minimized or refreshed. This

method is used for drawing different strings, figures, and images on the applet window.

  * stop( ) method - called when the browser moves off the applet?s page.

  * destroy( ) method - called when the browser is finished with the applet.


1.public void init():-when applet is first time loaded in jvm

2.public void start():-this method invokes when applet starts(means when applet displaying on screen)

3.public void paint(Graphics g):-this method invokes automatically to draw some text or images or drawing on canvas...

4.public void stop():-invokes when applet programs stop..

5.public void distroy():-invokes when applet window closed...


Why does my applet work with Appletviewer, but not with a browser?

I tried to run two of the applets in the examples directory of the distribution. I installed the WebLogic classes on my local machine (NT server) and on another machine (a Windows 95 client). I am not using any browsers, just trying to run the applets with Appletviewer. The applets work fine when I run Appletviewer from the NT server, but do not work at all from the Windows 95 client.

A. There are two possible problems: Either the CODEBASE tag is not properly set in the applet HTML file, or the class files are not properly loaded on the HTTP server.

The applet works on the NT server because you installed the WebLogic distribution on your NT server. Even if the applet cannot successfully load the necessary classes from the HTTP server, it does find them in your local CLASSPATH. But when you try to run it from the Windows 95 client, the applet must load the classes over the wire from the HTTP server, and if you haven't installed them correctly, it will fail.

Hi I am Pluto.