Industrial Training

TECH MAHINDRA Core Java Campus Interview Question Answer


What is the use of transient?

It is an indicator to the JVM that those variables should not be persisted. It is the users responsibility to initialize the value when read back from the storage.


What are the different level lockings using the synchronization keyword?

Class level lock Object level lock Method level lock Block level lock


What is the use of preparedstatement?

Preparedstatements are precompiled statements. It is mainly used to speed up the process of inserting/updating/deleting especially when there is a bulk processing.


What is callable statement? Tell me the way to get the callable statement?

Callablestatements are used to invoke the stored procedures. You can obtain the callablestatement from Connection using the following methods prepareCall(String sql) prepareCall(String sql, int resultSetType, int resultSetConcurrency)



In a statement, I am executing a batch. What is the result of the execution?

It returns the int array. The array contains the affected row count in the corresponding index of the SQL.


Can a abstract method have the static qualifier?

No


What are the different types of qualifier and what is the default qualifier?

Public, protected, private, package (default)


What is the super class of Hashtable?

Dictionary


What is a lightweight component?

Lightweight components are the one which doesn’t go with the native call to obtain the graphical units. They share their parent component graphical units to render them. Example, Swing components


What is a heavyweight component?

For every paint call, there will be a native call to get the graphical units. Example, AWT.


What is an applet?

Applet is a program which can get downloaded into a client environment and start executing there.


What do you mean by a Classloader

Classloader is the one which loads the classes into the JVM.


What are the implicit packages that need not get imported into a class file?

java.lang


What is the difference between lightweight and heavyweight component?

Lightweight components reuses its parents graphical units. Heavyweight components goes with the native graphical unit for every component. Lightweight components are faster than the heavyweight components.


What are the ways in which you can instantiate a thread?

Using Thread class By implementing the Runnable interface and giving that handle to the Thread class.



What are the states of a thread?

1. New 2. Runnable 3. Not Runnable 4. Dead


What is a socket?

A socket is an endpoint for communication between two machines.


How will you establish the connection between the servlet and an applet?

Using the URL, I will create the connection URL. Then by openConnection method of the URL, I will establish the connection, through which I can be able to exchange data.


What are the threads will start, when you start the java program?

Finalizer, Main, Reference Handler, Signal Dispatcher


What is the relationship between local interfaces and container-managed relationships?

Entity beans that have container-managed relationships with other entity beans, must be accessed in the same local scope as those related beans, and therefore typically provide a local client view. In order to be the target of a container-managed relationship, an entity bean with container-managed persistence must provide a local interface.


What does a remove method do for different cases of beans?

Stateless Session : Does not do anything to the bean as moving the bean from free pool to cache are managed by the container depending on load. Stateful Session: Removes the bean from the cache. Entity Bean: Deletes the bean (data) from persistent storage



How does a container-managed relationship work?

An entity bean accesses related entity beans by means of the accessor methods for its container-managed relationship fields, which are specified by the cmr-field elements of its abstract persistence schema defined in the deployment descriptor. Entity bean relationships are defined in terms of the local interfaces of the related beans, and the view an entity bean presents to its related beans is defined by its local home and local interfaces. Thus, an entity bean can be the target of a relationship from another entity bean only if it has a local interface.


What is the new basic requirement for a CMP entity bean class in 2.0 from that of ejb 1.1?

It must be abstract class. The container extends it and implements methods which are required for managing the relationships



What are the basic classes required in the client for invoking an EJB?

The home and the remote interfaces, the implementation of the Naming Context Factory, the stubs and skeletons. In some App servers the stubs and the skeletons can be dynamically downloaded from the server


What is the difference between Message Driven Beans and Stateless Session beans?

In several ways, the dynamic creation and allocation of message-driven bean instances mimics the behavior of stateless session EJB instances, which exist only for the duration of a particular method call. However, message-driven beans are different from stateless session EJBs (and other types of EJBs) in several significant ways:

  1. Message-driven beans process multiple JMS messages asynchronously, rather than processing a serialized sequence of method calls.

  2. Message-driven beans have no home or remote interface, and therefore cannot be directly accessed by internal or external clients. Clients interact with message-driven beans only indirectly, by sending a message to a JMS Queue or Topic.   3. Only the container directly interacts with a message-driven bean by creating bean instances and passing JMS messages to those instances as necessary.

  4. The Container maintains the entire lifecycle of a message-driven bean; instances cannot be created or removed as a result of client requests or other API calls.


Hi I am Pluto.