Saturday, December 12, 2009

Java Fundamental-IV



1. What are types of J2EE clients?
Answer: J2EE clients are the software that access the services components installed on the J2EE container. Following are the J2EE clients:
a) Applets
b) Java-Web Start clients
c) Wireless clients
d) Web applications


2. What do you understand by JTA and JTS?
Answer: JTA stands for Java Transaction API and JTS stands for Java Transaction Service. JTA provides a standard interface which allows the developers to demarcate transactions in a manner that is independent of the transaction manager implementation. The J2EE SDK uses the JTA transaction manager to implement the transaction. The code developed by developers does not calls the JTS methods directly, but only invokes the JTA methods. Then JTA internally invokes the JTS routines. JTA is a high level transaction interface used by the application code to control the transaction.



3. What is JAXP?
Answer: The Java API for XML Processing (JAXP) enables applications to parse and transform XML documents independent of a particular XML processing implementation. JAXP or Java API for XML Parsing is an optional API provided by Javasoft. It provides basic functionality for reading, manipulating, and generating XML documents through pure Java APIs. It is a thin and lightweight API that provides a standard way to seamlessly integrate any XML-compliant parser with a Java application.


4. What is difference between Java Bean and Enterprise Java Bean?
Answer: Java Bean as is a plain java class with member variables and getter setter methods. Java Beans are defined under JavaBeans specification as Java-Based software component model which includes the features like introspection, customization, events, properties and persistence.
Enterprise JavaBeans or EJBs for short are Java-based software components that comply with Java's EJB specification. EJBs are delpoyed on the EJB container and executes in the EJB container. EJB is not that simple, it is used for building distributed applications. Examples of EJB are Session Bean, Entity Bean and Message Driven Bean. EJB is used for server side programming whereas java bean is a client side. Bean is only development but the EJB is developed and then deploy on EJB Container.


5. What is the difference between JTS and JTA?
Answer: In any J2EE application transaction management is one of the most crucial requirements of the application. Given the complexity of today's business requirements, transaction processing occupies one of the most complex segments of enterprise level distributed applications to build, deploy and maintain. JTS specifies the implementation of a Java transaction manager. JTS specifies the implementation of a Transaction Manager which supports the Java Transaction API (JTA) 1.0 This transaction manager supports the JTA, using which application servers can be built to support transactional Java applications. Internally the JTS implements the Java mapping of the OMG OTS 1.1 specifications. The Java mapping is specified in two packages: org.omg.CosTransactions and org.omg.CosTSPortability. The JTS thus provides a new architecture for transactional application servers and applications, while complying to the OMG OTS 1.1 interfaces internally. This allows the JTA compliant applications to interoperate with other OTS 1.1 complaint applications through the standard IIOP. Java-based applications and Java-based application servers access transaction management functionality via the JTA interfaces. The JTA interacts with a transaction management implementation via JTS. Similarly, the JTS can access resources via the JTA XA interfaces or can access OTS-enabled non-XA resources. JTS implementations can interoperate via CORBA OTS interfaces.


The JTA specifies an architecture for building transactional application servers and defines a set of interfaces for various components of this architecture. The components are: the application, resource managers, and the application server. The JTA specifies standard interfaces for Java-based applications and application servers to interact with transactions, transaction managers, and resource managers JTA transaction management provides a set of interfaces utilized by an application server to manage the beginning and completion of transactions. Transaction synchronization and propagation services are also provided under the domain of transaction management.


In the Java transaction model, the Java application components can conduct transactional operations on JTA compliant resources via the JTS. The JTS acts as a layer over the OTS. The applications can therefore initiate global transactions to include other OTS transaction managers, or participate in global transactions initiated by other OTS compliant transaction managers.


6. Can Entity Beans have no create() methods?
Answer: Entity Beans can have no create() methods. Entity Beans have no create() method, when entity bean is not used to store the data in the database. In this case entity bean is used to retrieve the data from database.


7. What are the call back methods in Session bean?
Answer: Callback methods are called by the container to notify the important events to the beans in its life cycle. The callback methods are defined in the javax.ejb.EntityBean interface.The callback methods example are ejbCreate(), ejbPassivate(), and ejbActivate().


8. What is bean managed transaction?
Answer: In EJB transactions can be maintained by the container or developer can write own code to maintain the transaction. If a developer doesn’t want a Container to manage transactions, developer can write own code to maintain the database transaction.


9. What are transaction isolation levels in EJB?
Answer: Thre are four levels of transaction isolation are:
* Uncommitted Read
* Committed Read
* Repeatable Read
* Serializable
The four transaction isolation levels and the corresponding behaviors are described below:
Isolation Level Dirty Read Non-Repeatable Read Phantom Read
Read Uncommitted Possible Possible Possible
Read Committed Not possible Possible Possible
Repeatable Read Not possible Not possible Possible
Serializable Not possible Not possible Not possible


10. What is the use of Object and Class Classes?
Answer: The Object class is the superclass of all other classes and it is highest-level class in the Java class hierarchy. Instances of the class Class represent classes and interfaces in a running Java application. Every array also belongs to a class that is reflected as a Class object that is shared by all arrays with the same element type and number of dimensions. The primitive Java types (boolean, byte, char, short, int, long, float, and double), and the keyword void are also represented as Class objects.




11. Differentiate between a Class and an Object?
Answer: A Class is only the definition or prototype of real life object. Whereas an object is an instance or living representation of real life object. Every object belongs to a class and every class contains one or more related objects.


12. What do you understand by a variable?
Answer: The variables plays very important role in computer programming. Variables enable programmers to write flexible programs. It is a memory location that has been named so that it can be easily be referred in the program. The variable is used to hold the data and it can be changed changed during the course of the execution of the program.


13. What do you understand by numeric promotion?
Answer: The Numeric promotion is the conversion of a smaller numeric type to a larger numeric type, so that integer and floating-point operations may take place. In the numerical promotion process the byte, char, and short values are converted to int values. The int values are also converted to long values, if necessary. The long and float values are converted to double values, as required


14. What do you understand by casting in java language?
Answer: The process of converting one datatype to another in Java language is called Casting.


15. What are the types of casting?
Answer: There are two types of casting in Java, these are Implicit casting and explicit casting.


16. What is Implicit casting?
Answer: Implicit casting is the process of simply assigning one entity to another without any transformation guidance to the compiler. This type of casting is not permitted in all kinds of transformations and may not workout for all application scenarios.


Example:
int i = 4000;
long h = i; //Implicit casting


17. What is explicit casting?
Answer: Explicit casting in the process in which the complier are specifically informed to about transforming the object.
long ln = 700.20;
t = (int) ln; //Explicit casting


18. What do you understand by downcasting?
Answer: The process of Downcasting refers to the casting from a general to a more specific type, i.e. casting down the hierarchy


19. What do you understand by downcasting?
Answer: The process of Downcasting refers to the casting from a general to a more specific type, i.e. casting down the hierarchy


20. What do you understand by final value?
Answer: FINAL for a variable: value is constant. FINAL for a method: cannot be overridden. FINAL for a class: cannot be derived

No comments:

Post a Comment

Open Researcher and Contributor ID (ORCID)

Search Aptipedia