Java Interview Questions - Part 5 of 7

Is “abc” a primitive value?
The String literal “abc” is not a primitive value. It is a String object.
---------------------------------------------------------------------------------------------------------------------

What restrictions are placed on the values of each case of a switch statement?
During compilation, the values of each case of a switch statement must evaluate to a value that can be promoted to an int value.
---------------------------------------------------------------------------------------------------------------------

What is the query used to display all tables names in SQL Server (Query analyzer)?
select * from information_schema.tables
---------------------------------------------------------------------------------------------------------------------

Is it possible to write two EJB’s that share the same Remote and Home interfaces, and have different bean classes? if so, what are the advantages/disadvantages?
It’s certainly possible. In fact, there’s an example that ships with the Inprise Application Server of an Account interface with separate implementations for CheckingAccount and SavingsAccount, one of which was CMP and one of which was BMP.
---------------------------------------------------------------------------------------------------------------------

What is garbage collection?
What is the process that is responsible for doing that in java? - Reclaiming the unused memory by the invalid objects. Garbage collector is responsible for this process
---------------------------------------------------------------------------------------------------------------------

What kind of thread is the Garbage collector thread?
It is a daemon thread.
---------------------------------------------------------------------------------------------------------------------

What is a Marker Interface?
An interface with no methods. Example: Serializable, Remote, Cloneable
---------------------------------------------------------------------------------------------------------------------

What interface do you implement to do the sorting?
Comparable
---------------------------------------------------------------------------------------------------------------------

What is the eligibility for a object to get cloned?
It must implement the Cloneable interface
---------------------------------------------------------------------------------------------------------------------

J2EE EJB interview questions

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 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 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.
---------------------------------------------------------------------------------------------------------------------

What is the sequence for calling the methods by AWT for applets?
When an applet begins, the AWT calls the following methods, in this sequence:
init()
start()
paint()
When an applet is terminated, the following sequence of method calls takes place :

stop()
destroy()

No comments:

Post a Comment