Java J2EE Faqs

Embed Size (px)

Citation preview

  • 8/11/2019 Java J2EE Faqs

    1/27

    Edited By Mahendra Kumar Shrivas [[email protected]]- +919098759901

    Java Platform Question

    1. What is a platform?A platform is the hardware or software environment in which a program runs.

    Most platforms can be described as a combination of the operating system and

    hardware, like Windows 2000/XP, Linux, Solaris, and MacOS.

    2. What is the main difference between Java platform and other platforms?The Java platform differs from most other platforms in that it\s a

    software-only platform that runs on top of other hardware-based platforms.

    The Java platform has two components:

    a. The Java Virtual Machine (Java VM)

    b. The Java Application Programming Interface (Java API)

    3. What is the Java Virtual Machine?The Java Virtual Machine is a software that can be ported onto various

    hardware-based platforms.

    4. What is the Java API?The Java API is a large collection of ready-made software components that

    provide many useful capabilities, such as graphical user interface (GUI)widgets.

    5. What is the package?

    The package is a Java namespace or part of Java libraries. The Java API isgrouped into libraries of related classes and interfaces; these libraries are

    known as packages.

    6. What is native code?The native code is code that after you compile it, the compiled code runs

    on a specific hardware platform.

    7. Is Java code slower than native code?

    Not really. As a platform-independent environment, the Java platform can be

    a bit slower than native code. However, smart compilers, well-tuned

    interpreters, and just-in-time bytecode compilers can bring performance close

    to that of native code without threatening portability.

    Java Basic Question

    8. What are the advantages of OOPL?Object oriented programming languages directly

    represent the real life objects. The features of OOPL as inhreitance, polymorphism,

    encapsulation makes it powerful.

    9. What do mean by polymorphisum, inheritance, encapsulation?Ans: Polymorhisum:

    is a feature of OOPl that at run time depending upon the type of object the appropriatemethod is called.

    Inheritance: is a feature of OOPL that represents the "is a" relationship between different

  • 8/11/2019 Java J2EE Faqs

    2/27

    Edited By Mahendra Kumar Shrivas [[email protected]]- +919098759901

    objects(classes). Say in real life a manager is a employee. So in OOPL manger class is

    inherited from the employee class.Encapsulation: is a feature of OOPL that is used to hide the information.

    10.

    What do you mean by static methods?Ans: By using the static method there is no needcreating an object of that class to use that method. We can directly call that method on

    that class. For example, say class A has static function f(), then we can call f() function as

    A.f(). There is no need of creating an object of class A.

    11.What do you mean by virtual methods?Ans: virtual methods are used to use the

    polymorhism feature in C++. Say class A is inherited from class B. If we declare say

    fuction f() as virtual in class B and override the same function in class A then at runtime

    appropriate method of the class will be called depending upon the type of the object.

    12.What are the disadvantages of using threads?

    Ans: DeadLock.

    13. Write the Java code to declare any constant (say gravitational constant) and to getits value Ans: Class ABC

    {

    static final float GRAVITATIONAL_CONSTANT = 9.8;public void getConstant()

    {

    System.out.println("Gravitational_Constant: " + GRAVITATIONAL_CONSTANT);

    }

    }

    14.What do you mean by multiple inheritance in C++ ?Ans: Multiple inheritance is a

    feature in C++ by which one class can be of different types. Say class teachingAssistantis inherited from two classes say teacher and Student.

    15. Can you write Java code for declaration of multiple inheritance in Java ?

    Ans: Class C extends A implements B{

    }

    16.What is a class?A class is a blueprint, or prototype, that defines the variables and the

    methods common to all objects of a certain kind.

    17.What is an object? An object is a software bundle of variables and related methods. an

    instance of a class depicting the state and behavior at that particular time in real world.18.What is a method? Encapsulation of a functionality which can be called to perform

    specific tasks.

    19.What is encapsulation? Explain with an example.Encapsulation is the term given to

    the process of hiding the implementation details of the object. Once an object isencapsulated, its implementation details are not immediately accessible any more. Instead

    they are packaged and are only indirectly accessible via the interface of the object

  • 8/11/2019 Java J2EE Faqs

    3/27

    Edited By Mahendra Kumar Shrivas [[email protected]]- +919098759901

    20.What is inheritance? Explain with an example.Inheritance in object oriented

    programming means that a class of objects can inherit properties and methods fromanother class of objects.

    21.

    What is polymorphism? Explain with an example. In object-oriented programming,polymorphism refers to a programming languages ability to process objects differently

    depending on their data type or class. More specifically, it is the ability to redefine

    methods for derived classes. For example, given a base class shape, polymorphism

    enables the programmer to define different area methods for any number of derived

    classes, such as circles, rectangles and triangles. No matter what shape an object is,

    applying the area method to it will return the correct results. Polymorphism is considered

    to be a requirement of any true object-oriented programming language

    22.Is multiple inheritance allowed in Java? No, multiple inheritance is not allowed inJava.

    23.What is interpreter and compiler? Java interpreter converts the high level language

    code into a intermediate form in Java called as bytecode, and then executes it, where as acompiler converts the high level language code to machine language making it very

    hardware specific24.What is JVM?The Java interpreter along with the runtime environment required to run

    the Java application in called as Java virtual machine(JVM)

    25.What are the different types of modifiers? There are access modifiers and there are

    other identifiers. Access modifiers are public, protected and private. Other are final andstatic.

    26.What are the access modifiers in Java? There are 3 access modifiers. Public, protected

    and private, and the default one if no identifier is specified is called friendly, but

    programmer cannot specify the friendly identifier explicitly.

    27.

    What is a wrapper class?They are classes that wrap a primitive data type so it can beused as a object

    28.What is a static variable and static method? Whats the difference between two?The

    modifier static can be used with a variable and method. When declared as static variable,there is only one variable no matter how instances are created, this variable is initialized

    when the class is loaded. Static method do not need a class to be instantiated to be called,

    also a non static method cannot be called from static method.29.What is garbage collection?Garbage Collection is a thread that runs to reclaim the

    memory by destroying the objects that cannot be referenced anymore.

    30.What is abstract class?Abstract class is a class that needs to be extended and its

    methods implemented, class has to be declared abstract if it has one or more abstract

    methods.31.

    What is meant by final class, methods and variables? This modifier can be applied to

    class method and variable. When declared as final class the class cannot be extended.

    When declared as final variable, its value cannot be changed if is primitive value, if it is a

    reference to the object it will always refer to the same object, internal attributes of the

    object can be changed.

    32.What is interface?Interface is a contact that can be implemented by a class; it has

    method that needs implementation.

  • 8/11/2019 Java J2EE Faqs

    4/27

  • 8/11/2019 Java J2EE Faqs

    5/27

    Edited By Mahendra Kumar Shrivas [[email protected]]- +919098759901

    46.What are the three types of priority?MAX_PRIORITY which is 10, MIN_PRIORITY

    which is 1, NORM_PRIORITY which is 5.47.What is the use of synchronizations?Every object has a lock, when a synchronized

    keyword is used on a piece of code the, lock must be obtained by the thread first toexecute that code, other threads will not be allowed to execute that piece of code till this

    lock is released.

    48.What are synchronized methods and synchronized statements?Synchronized

    methods are methods that are used to control access to an object. For example, a thread

    only executes a synchronized method after it has acquired the lock for the methods

    object or class. Synchronized statements are similar to synchronized methods. A

    synchronized statement can only be executed after a thread has acquired the lock for the

    object or class referenced in the synchronized statement.49.

    What are different ways in which a thread can enter the waiting state?A thread can

    enter the waiting state by invoking its sleep() method, blocking on I/O, unsuccessfully

    attempting to acquire an objects lock, or invoking an objects wait() method. It can alsoenter the waiting state by invoking its (deprecated) suspend() method.

    50.Can a lock be acquired on a class?Yes, a lock can be acquired on a class. This lock isacquired on the classs Class object.

    51.Whats new with the stop(), suspend() and resume() methods in new JDK 1.2?The

    stop(), suspend() and resume() methods have been deprecated in JDK 1.2.

    52.What is the preferred size of a component?The preferred size of a component is theminimum component size that will allow the component to display normally.

    53.What method is used to specify a containers layout?The setLayout() method is used

    to specify a containers layout. For example, setLayout(new FlowLayout()); will be set

    the layout as FlowLayout.

    54.

    Which containers use a FlowLayout as their default layout?The Panel and Appletclasses use the FlowLayout as their default layout.

    55.What state does a thread enter when it terminates its processing?When a thread

    terminates its processing, it enters the dead state.56.

    What is the Collections API?The Collections API is a set of classes and interfaces that

    support operations on collections of objects. One example of class in Collections API is

    Vector and Set and List are examples of interfaces in Collections API.57.What is the List interface?The List interface provides support for ordered collections

    of objects. It may or may not allow duplicate elements but the elements must be ordered.

    58.How does Java handle integer overflows and underflows?It uses those low order

    bytes of the result that can fit into the size of the type allowed by the operation.

    59.

    What is the Vector class?The Vector class provides the capability to implement agrowable array of objects. The main visible advantage of this class is programmer

    neednt to worry about the number of elements in the Vector.

    60.What modifiers may be used with an inner class that is a member of an outer class?A (non-local) inner class may be declared as public, protected, private, static, final, or

    abstract.

    61.If a method is declared as protected, where may the method be accessed?A

    protected method may only be accessed by classes or interfaces of the same package or

    by subclasses of the class in which it is declared.

  • 8/11/2019 Java J2EE Faqs

    6/27

    Edited By Mahendra Kumar Shrivas [[email protected]]- +919098759901

    62.What is an Iterator interface?The Iterator interface is used to step through the

    elements of a Collection.

    63.How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8characters?Unicode requires 16 bits, ASCII require 7 bits (although the ASCIIcharacter set uses only 7 bits, it is usually represented as 8 bits), UTF-8 represents

    characters using 8, 16, and 18 bit patterns, UTF-16 uses 16-bit and larger bit patterns

    64.What is the difference between yielding and sleeping?Yielding means a thread

    returning to a ready state either from waiting, running or after creation, where as sleeping

    refers a thread going to a waiting state from running state. With reference to Java, when a

    task invokes its yield() method, it returns to the ready state and when a task invokes its

    sleep() method, it returns to the waiting state

    65.What are wrapper classes?Wrapper classes are classes that allow primitive types to beaccessed as objects. For example, Integer, Double. These classes contain many methods

    which can be used to manipulate basic data types

    66.

    Does garbage collection guarantee that a program will not run out of memory?No,it doesnt. It is possible for programs to use up memory resources faster than they are

    garbage collected. It is also possible for programs to create objects that are not subject togarbage collection. The main purpose of Garbage Collector is recover the memory from

    the objects which are no longer required when more memory is needed.

    67.Name Component subclasses that support painting?The following classes support

    painting: Canvas, Frame, Panel, and Applet.68.

    What is a native method?A native method is a method that is implemented in a

    language other than Java. For example, one method may be written in C and can be called

    in Java.

    69.How can you write a loop indefinitely?

    for(;;) //for loop

    while(true); //always true

    70.Can an anonymous class be declared as implementing an interface and extending aclass?An anonymous class may implement an interface or extend a superclass, but maynot be declared to do both.

    71.What is the purpose of finalization?The purpose of finalization is to give an

    unreachable object the opportunity to perform any cleanup processing before the object is

    garbage collected. For example, closing a opened file, closing a opened databaseConnection.

    72.

    What invokes a threads run() method?After a thread is started, via its start() methodor that of the Thread class, the JVM invokes the threads run() method when the thread is

    initially executed.

    73.What is the GregorianCalendar class?The GregorianCalendar provides support for

    traditional Western calendars.

    74.What is the SimpleTimeZone class?The SimpleTimeZone class provides support for a

    Gregorian calendar.

  • 8/11/2019 Java J2EE Faqs

    7/27

    Edited By Mahendra Kumar Shrivas [[email protected]]- +919098759901

    75.What is the Properties class?The properties class is a subclass of Hashtable that can be

    read from or written to a stream. It also provides the capability to specify a set of defaultvalues to be used.

    76.

    What is the purpose of the Runtime class?The purpose of the Runtime class is toprovide access to the Java runtime system.

    77.What is the purpose of the System class?The purpose of the System class is to provide

    access to system resources.

    78.What is the purpose of the finally clause of a try-catch-finally statement?The finally

    clause is used to provide the capability to execute code no matter whether or not an

    exception is thrown or caught. For example,

    try

    {

    //some statements

    }catch

    {// statements when exception is cought

    }finally{

    //statements executed whether exception occurs or not

    }

    79.What is the Locale class?The Locale class is used to tailor program output to the

    conventions of a particular geographic, political, or cultural region.80.

    What must a class do to implement an interface?It must provide all of the methods in

    the interface and identify the interface in its implements clause.

    81.What is the serialization?The serialization is a kind of mechanism that makes a class or a beanpersistence by having its properties or fields and state information saved and

    restored to and from storage.

    82.How to make a class or a bean serializable?

    By implementing either the java.io.Serializable interface, or thejava.io.Externalizable interface. As long as one class in a class\s

    inheritance hierarchy implements Serializable or Externalizable, that class is

    serializable.

    83.How many methods in the Serializable interface?There is no method in the Serializable interface. The Serializable

    interface acts as a marker, telling the object serialization tools that your

    class is serializable.

  • 8/11/2019 Java J2EE Faqs

    8/27

    Edited By Mahendra Kumar Shrivas [[email protected]]- +919098759901

    84.How many methods in the Externalizable interface?There are two methods in the Externalizable interface. You have toimplement these two methods in order to make your class externalizable. These

    two methods are readExternal() and writeExternal().85.

    What is the difference between Serializalble and Externalizable interface? When you

    use Serializable interface, your class is serialized automatically

    by default. But you can override writeObject() and readObject() two methods to

    control more complex object serailization process. When you use Externalizable

    interface, you have a complete control over your class\s serialization

    process.

    86.What is a transient variable?A transient variable is a variable that may not be serialized. If you don\twant some field not to be serialized, you can mark that field transient or

    static.

    87.

    Which containers use a border layout as their default layout?The window, Frame and Dialog classes use a border layout as their default

    layout.

    88.How are Observer and Observable used?Objects that subclass the Observable class maintain a list of observers.

    When an Observable object is updated it invokes the update() method of each of

    its observers to notify the observers that it has changed state. The Observerinterface is implemented by objects that observe Observable objects.

    89.What is synchronization and why is it important?With respect to multithreading, synchronization is the capability to

    control the access of multiple threads to shared resources. Without

    synchronization, it is possible for one thread to modify a shared object whileanother thread is in the process of using or updating that object\s value.

    This often causes dirty data and leads to significant errors.

    90.Is Java a super set of JavaScript?No. They are completely different. Some syntax may be similar.

    91.What is user defined exception?Ans: There are many exception defined by java which are used to track the run timeexceptions and act accordingly. User can also define his exceptions that can be thrown in

    the same way java exceptions.

    92.What do you know about the garbage collector?Ans: Garbage collector is used to recollect memory from the us=nused objects. They are

    the objects that are no longer needed because of function or class scope is going to finish.93.

    What gives Java its write once and run anywhere nature?- Java is compiled to be a

    byte code which is the intermediate language between source code and machine code.

    This byte code is not platform specific and hence can be fed to any platform. After being

    fed to the JVM, which is specific to a particular operating system, the code platform

    specific machine code is generated thus making java platform independent.

    94.What are the four pillar of OOP?- Abstraction, Encapsulation, Polymorphism and

    Inheritance.

  • 8/11/2019 Java J2EE Faqs

    9/27

    Edited By Mahendra Kumar Shrivas [[email protected]]- +919098759901

    95.Difference between a Class and an Object?- A class is a definition or prototype

    whereas an object is an instance or living representation of the prototype.96.What is the difference between method overriding and overloading?- Overriding is a

    method with the same name and arguments as in a parent, whereas overloading is thesame method name but different arguments.

    97.What is a stateless protocol?- Without getting into lengthy debates, it is generally

    accepted that protocols like HTTP are stateless i.e. there is no retention of state between a

    transaction which is a single request response combination.

    98.What is constructor chaining and how is it achieved in Java?- A child object

    constructor always first needs to construct its parent (which in turn calls its parent

    constructor.). In Java it is done via an implicit call to the no-args constructor as the first

    statement.99.

    What is passed by ref and what by value?- All Java method arguments are passed by

    value. However, Java does manipulate objects by reference, and all object variables

    themselves are references100. Can RMI and Corba based applications interact?- Yes they can. RMI is

    available with IIOP as the transport protocol instead of JRMP.

    101. You can create a String object as String str = abc"; Why cant a buttonobject be created as Button bt = abc";? Explain- The main reason you cannot create

    a button by Button bt1= abc"; is because abc is a literal string (something slightly

    different than a String object, by the way) and bt1 is a Button object. The only object inJava that can be assigned a literal String is java.lang.String. Important to note that you are

    NOT calling a java.lang.String constuctor when you type String s = abc";

    102. What does the abstract keyword mean in front of a method? A class?-

    Abstract keyword declares either a method or a class. If a method has a abstract keyword

    in front of it,it is called abstract method.Abstract method hs no body.It has onlyarguments and return type.Abstract methods act as placeholder methods that are

    implemented in the subclasses. Abstract classes cant be instantiated.If a class is declared

    as abstract,no objects of that class can be created.If a class contains any abstract methodit must be declared as abstract.

    103. How many methods do u implement if implement the Serializable Interface?- The Serializable interface is just a marker interface, with no methods of its own toimplement. Other marker interfaces are

    java.rmi.Remote

    java.util.EventListener

    104. What are the practical benefits, if any, of importing a specific class ratherthan an entire package (e.g. import java.net.* versus import java.net.Socket)?- It

    makes no difference in the generated class files since only the classes that are actuallyused are referenced by the generated class file. There is another practical benefit to

    importing single classes, and this arises when two (or more) packages have classes with

    the same name. Take java.util.Timer and javax.swing.Timer, for example. If I import

    java.util.* and javax.swing.* and then try to use Timer", I get an error while compiling

    (the class name is ambiguous between both packages). Lets say what you really wanted

  • 8/11/2019 Java J2EE Faqs

    10/27

    Edited By Mahendra Kumar Shrivas [[email protected]]- +919098759901

    was the javax.swing.Timer class, and the only classes you plan on using in java.util are

    Collection and HashMap. In this case, some people will prefer to importjava.util.Collection and import java.util.HashMap instead of importing java.util.*. This

    will now allow them to use Timer, Collection, HashMap, and other javax.swing classeswithout using fully qualified class names in.

    105. What is the difference between logical data independence and physical data

    independence?- Logical Data Independence - meaning immunity of external schemas to

    changed in conceptual schema. Physical Data Independence - meaning immunity of

    conceptual schema to changes in the internal schema.

    106. What is a user-defined exception?- Apart from the exceptions already defined

    in Java package libraries, user can define his own exception classes by extending

    Exception class.107.

    Describe the visitor design pattern?- Represents an operation to be performed

    on the elements of an object structure. Visitor lets you define a new operation without

    changing the classes of the elements on which it operates. The root of a class hierarchydefines an abstract method to accept a visitor. Subclasses implement this method with

    visitor.visit(this). The Visitor interface has visit methods for all subclasses of thebaseclass in the hierarchy.

    108. What is the Collections API?- The Collections API is a set of classes and

    interfaces that support operations on collections of objects

    109. What is the List interface?- The List interface provides support for orderedcollections of objects.

    110. What is the Vector class?- The Vector class provides the capability to

    implement a growable array of objects

    111. What is an Iterator interface?- The Iterator interface is used to step through the

    elements of a Collection112. Which java.util classes and interfaces support event handling?- The

    EventObject class and the EventListener interface support event processing

    113. What is the GregorianCalendar class?- The GregorianCalendar providessupport for traditional Western calendars

    114. What is the Locale class?- The Locale class is used to tailor program output to

    the conventions of a particular geographic, political, or cultural region115. What is the SimpleTimeZone class?- The SimpleTimeZone class provides

    support for a Gregorian calendar

    116. What is the Map interface?- The Map interface replaces the JDK 1.1 Dictionary

    class and is used associate keys with values

    117.

    What is the highest-level event class of the event-delegation model?- Thejava.util.EventObject class is the highest-level class in the event-delegation class

    hierarchy

    118. What is the Collection interface?- The Collection interface provides support for

    the implementation of a mathematical bag - an unordered collection of objects that may

    contain duplicates

    119. What is the Set interface?- The Set interface provides methods for accessing the

    elements of a finite mathematical set. Sets do not allow duplicate elements

  • 8/11/2019 Java J2EE Faqs

    11/27

  • 8/11/2019 Java J2EE Faqs

    12/27

    Edited By Mahendra Kumar Shrivas [[email protected]]- +919098759901

    134. What method must be implemented by all threads?- All tasks must implement

    the run() method, whether they are a subclass of Thread or implement the Runnableinterface.

    135.

    What are the two basic ways in which classes that can be run as threads may

    be defined?- A thread class may be declared as a subclass of Thread, or it may

    implement the Runnable interface.

    Java AWT Questions

    1.

    What is meant by Controls and what are different types of controls?- Controls arecomponenets that allow a user to interact with your application. The AWT supports the

    following types of controls:

    o Labels

    o Push buttonso Check boxeso

    Choice listso

    Lists

    o

    Scroll bars

    o

    Text components

    These controls are subclasses of Component.

    2. Which method of the component class is used to set the position and the size of a

    component?- setBounds(). The following code snippet explains this:3. txtName.setBounds(x,y,width,height);

    places upper left corner of the text field txtName at point (x,y) with the width and heightof the text field set as width and height.

    4. Which TextComponent method is used to set a TextComponent to the read-onlystate?- setEditable()

    5. How can the Checkbox class be used to create a radio button?- By associating

    Checkbox objects with a CheckboxGroup.

    6. What methods are used to get and set the text label displayed by a Button object?-getLabel( ) and setLabel( )

    7. What is the difference between a Choice and a List?- Choice: A Choice is displayed

    in a compact form that requires you to pull it down to see the list of available choices.

    Only one item may be selected from a Choice. List: A List may be displayed in such a

    way that several List items are visible. A List supports the selection of one or more List

    items.

  • 8/11/2019 Java J2EE Faqs

    13/27

  • 8/11/2019 Java J2EE Faqs

    14/27

    Edited By Mahendra Kumar Shrivas [[email protected]]- +919098759901

    o FlowLayout: The elements of a FlowLayout are organized in a top to bottom, left

    to right fashion.o BorderLayout: The elements of a BorderLayout are organized at the borders

    (North, South, East and West) and the center of a container.o

    CardLayout: The elements of a CardLayout are stacked, one on top of the other,

    like a deck of cards.

    o

    GridLayout: The elements of a GridLayout are of equal size and are laid out using

    the square of a grid.

    o GridBagLayout:

    The elements of a GridBagLayout are organized according to a grid.However, the

    elements are of different sizes and may occupy more

    than one row or column of the grid. In addition, the rows and columns may havedifferent sizes.

    The default Layout Manager of Panel and Panel sub classes is FlowLayout.

    15.Can I add the same component to more than one container?- No. Adding a

    component to a container automatically removes it from any previous parent (container).

    16.How can we create a borderless window?- Create an instance of the Window class,give it a size, and show it on the screen.

    17. Frame aFrame = new Frame();

    18.

    Window aWindow = new Window(aFrame);

    19.

    aWindow.setLayout(new FlowLayout());

    20. aWindow.add(new Button("Press Me"));

    21.

    aWindow.getBounds(50,50,200,200);

    22.

    aWindow.show();

    23.

    Can I create a non-resizable windows? If so, how?- Yes. By using setResizable()method in class Frame.

    24.Which containers use a BorderLayout as their default layout? Which containers usea FlowLayout as their default layout?- The Window, Frame and Dialog classes use a

    BorderLayout as their default layout. The Panel and the Applet classes use the

    FlowLayout as their default layout.

    25.How do you change the current layout manager for a container?

    o Use the setLayout method

    o

    Once created you cannot change the current layout manager of a component

    o

    Use the setLayoutManager methodo

    Use the updateLayout method

    Answer: a.

    26.What is the difference between a MenuItem and a CheckboxMenuItem?- The

    CheckboxMenuItem class extends the MenuItem class to support a menu item that may

    be checked or unchecked.

    Java GUI Question

  • 8/11/2019 Java J2EE Faqs

    15/27

    Edited By Mahendra Kumar Shrivas [[email protected]]- +919098759901

    1. What advantage do Javas layout managers provide over traditional windowingsystems?- Java uses layout managers to lay out components in a consistent manneracross all windowing platforms. Since Javas layout managers arent tied to absolute

    sizing and positioning, they are able to accomodate platform-specific differences amongwindowing systems.

    2. What is the difference between the paint() and repaint() methods?- The paint()

    method supports painting via a Graphics object. The repaint() method is used to cause

    paint() to be invoked by the AWT painting thread.

    3. How can the Checkbox class be used to create a radio button?- By associating

    Checkbox objects with a CheckboxGroup

    4. What is the difference between a Choice and a List?- A Choice is displayed in a

    compact form that requires you to pull it down to see the list of available choices. Onlyone item may be selected from a Choice. A List may be displayed in such a way that

    several List items are visible. A List supports the selection of one or more List items.

    5.

    What interface is extended by AWT event listeners?- All AWT event listeners extendthe java.util.EventListener interface.

    6. What is a layout manager?- A layout manager is an object that is used to organizecomponents in a container

    7. Which Component subclass is used for drawing and painting?- Canvas

    8. What are the problems faced by Java programmers who dont use layout managers?

    - Without layout managers, Java programmers are faced with determining how their GUIwill be displayed across multiple windowing systems and finding a common sizing and

    positioning that will work within the constraints imposed by each windowing system

    9. What is the difference between a Scrollbar and a ScrollPane? (Swing) - A Scrollbar

    is a Component, but not a Container. A ScrollPane is a Container. A ScrollPane

    handles its own events and performs its own scrolling.

    Java Applet Questions

    1. 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 dynamicand interactive program that runs inside a Web page displayed by a Java-capable

    browser. We dont have the concept of Constructors in Applets. Applets can be invoked

    either through browser or through Appletviewer utility provided by JDK.

    2. What are the Applets Life Cycle methods? Explain them?- Following are methodsin the life cycle of an Applet:

    o

    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.

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

  • 8/11/2019 Java J2EE Faqs

    16/27

    Edited By Mahendra Kumar Shrivas [[email protected]]- +919098759901

    o 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.o stop( ) method - called when the browser moves off the applets page.o

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

    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:

    o

    init()

    o

    start()

    o paint()

    When an applet is terminated, the following sequence of method calls takes place :

    o

    stop()

    o

    destroy()

    4. How do Applets differ from Applications?- Following are the main differences:

    Application: Stand Alone, doesnt need

    web-browser. Applet: Needs no explicit installation on local machine. Can be transferred

    through Internet on to the local machine and may run as part of web-browser.

    Application: Execution starts with main() method. Doesnt work if main is not there.Applet: Execution starts with init() method. Application: May or may not be a GUI.

    Applet: Must run within a GUI (Using AWT). This is essential feature of applets.5.

    Can we pass parameters to an applet from HTML page to an applet? How?- We

    can pass parameters to an applet using tag in the following way:o

    o

    Access those parameters inside the applet is done by calling getParameter() method

    inside the applet. Note that getParameter() method returns String value corresponding tothe parameter name.

    6. How do we read number information from my applets parameters, given that

    Applets getParameter() method returns a string?- Use the parseInt() method in the Integer Class, the Float(String) constructor or

    parseFloat() method in the Class Float, or theDouble(String) constructor or parseDoulbl() method in the class Double.

    7. How can I arrange for different applets on a web page to communicate with each

    other?- Name your applets inside the Applet tag and invoke AppletContexts getApplet()

    method in your applet code to obtain references to the

    other applets on the page.8. How do I select a URL from my Applet and send the browser to that page?- Ask the

    applet for its applet context and invoke showDocument() on that context object.

  • 8/11/2019 Java J2EE Faqs

    17/27

    Edited By Mahendra Kumar Shrivas [[email protected]]- +919098759901

    9.

    URL targetURL;

    10.

    String URLString

    11. AppletContext context = getAppletContext();

    12.

    try13.

    {

    14. targetURL = new URL(URLString);

    15. }

    16.

    catch (MalformedURLException e)

    17.

    {

    18. // Code for recover from the exception

    19.

    }

    20.

    context. showDocument (targetURL);

    21.Can applets on different pages communicate with each other?- No, Not Directly. The applets will exchange the information at one meeting place either

    on the local file system or at remote system.

    22.How do I determine the width and height of my application?

    - Use the getSize() method, which the Applet class inherits from the Component class inthe Java.awt package. The getSize() method returns the size of the applet as a Dimensionobject, from which you extract separate width, height fields. The following code snippet

    explains this:23. Dimension dim = getSize();

    24.

    int appletwidth = dim.width();

    25.

    int appletheight = dim.height();

    26.Which classes and interfaces does Applet class consist?- Applet class consists of a

    single class, the Applet class and three interfaces: AppletContext, AppletStub, and

    AudioClip.

    27.What is AppletStub Interface?- The applet stub interface provides the means by which an applet and the browser

    communicate. Your code will not typically implement this interface.

    28.What tags are mandatory when creating HTML to display an applet?

    1.

    name, height, width

    2.

    code, name

    3.

    codebase, height, width

    4. code, height, width

    Correct answer is d.

    29.What are the Applets information methods?- The following are the Applets information methods: getAppletInfo() method: Returns a

    string describing the applet, its author, copyright information, etc. getParameterInfo( )

    method: Returns an array of string describing the applets parameters.

    30.What are the steps involved in Applet development?- Following are the steps

    involved in Applet development:o

    Create/Edit a Java source file. This file must contain a class which extends Applet

    class.o

    Compile your program using javac

  • 8/11/2019 Java J2EE Faqs

    18/27

    Edited By Mahendra Kumar Shrivas [[email protected]]- +919098759901

    o Execute the appletviewer, specifying the name of your applets source file or html

    file. In case the applet information is stored in html file then Applet can beinvoked using java enabled web browser.

    31.

    Which method is used to output a string to an applet? Which function is this method

    included in?- drawString( ) method is used to output a string to an applet. This method

    is included in the paint method of the Applet.

    Java database interview questions

    1. How do you call a Stored Procedure from JDBC? - The first step is to create a

    CallableStatement object. As with Statement and PreparedStatement objects, this is done

    with an open Connection object. A CallableStatement object contains a call to a stored

    procedure.2.

    CallableStatement cs =

    3.

    con.prepareCall("{call SHOW_SUPPLIERS}");4. ResultSet rs = cs.executeQuery();

    5. Is the JDBC-ODBC Bridge multi-threaded? - No. The JDBC-ODBC Bridge does not

    support concurrent access from different threads. The JDBC-ODBC Bridge uses

    synchronized methods to serialize all of the calls that it makes to ODBC. Multi-threadedJava programs may use the Bridge, but they wont get the advantages of multi-threading.

    6. Does the JDBC-ODBC Bridge support multiple concurrent open statements per

    connection? - No. You can open only one Statement object per connection when you are

    using the JDBC-ODBC Bridge.

    7. What is cold backup, hot backup, warm backup recovery? - Cold backup (All these

    files must be backed up at the same time, before the databaseis restarted). Hot backup

    (official name is online backup) is a backup taken of each tablespace while the databaseis running and is being accessed by the users.

    8. When we will Denormalize data? - Data denormalization is reverse procedure, carriedout purely for reasons of improving performance. It maybe efficient for a high-

    throughput system to replicate data for certain data.

    9. What is the advantage of using PreparedStatement? - If we are using

    PreparedStatement the execution time will be less. The PreparedStatement object

    contains not just an SQL statement, but the SQL statement that has been precompiled.

    This means that when the PreparedStatement is executed,the RDBMS can just run the

    PreparedStatements Sql statement without having to compile it first.10.What is a dirty read"? - Quite often in database processing, we come across the

    situation wherein one transaction can change a value, and a second transaction can readthis value before the original change has been committed or rolled back. This is known as

    a dirty read scenario because there is always the possibility that the first transaction may

    rollback the change, resulting in the second transaction having read an invalid value.

    While you can easily command a database to disallow dirty reads, this usually degrades

    the performance of your application due to the increased locking overhead. Disallowing

    dirty reads also leads to decreased system concurrency.

    11.What is Metadata and why should I use it? - Metadata (data about data) isinformation about one of two things: Database information (java.sql.DatabaseMetaData),

  • 8/11/2019 Java J2EE Faqs

    19/27

    Edited By Mahendra Kumar Shrivas [[email protected]]- +919098759901

    or Information about a specific ResultSet (java.sql.ResultSetMetaData). Use

    DatabaseMetaData to find information about your database, such as its capabilities andstructure. Use ResultSetMetaData to find information about the results of an SQL query,

    such as size and types of columns12.

    Different types of Transaction Isolation Levels? - The isolation level describes the

    degree to which the data being updated is visible to other transactions. This is important

    when two transactions are trying to read the same row of a table. Imagine two

    transactions: A and B. Here three types of inconsistencies can occur:

    o Dirty-read: A has changed a row, but has not committed the changes. B reads the

    uncommitted data but his view of the data may be wrong if A rolls back his

    changes and updates his own changes to the database.o

    Non-repeatable read: B performs a read, but A modifies or deletes that data later.If B reads the same row again, he will get different data.

    o

    Phantoms: A does a query on a set of rows to perform an operation. B modifies

    the table such that a query of A would have given a different result. The table maybe inconsistent.

    TRANSACTION_READ_UNCOMMITTED : DIRTY READS, NON-REPEATABLE

    READ AND PHANTOMS CAN OCCUR.TRANSACTION_READ_COMMITTED : DIRTY READS ARE PREVENTED, NON-REPEATABLE READ AND PHANTOMS CAN OCCUR.

    TRANSACTION_REPEATABLE_READ : DIRTY READS , NON-REPEATABLE

    READ ARE PREVENTED AND PHANTOMS CAN OCCUR.

    TRANSACTION_SERIALIZABLE : DIRTY READS, NON-REPEATABLE READ

    AND PHANTOMS ARE PREVENTED.

    13.What is 2 phase commit? - A 2-phase commit is an algorithm used to ensure the

    integrity of a committing transaction. In Phase 1, the transaction coordinator contacts

    potential participants in the transaction. The participants all agree to make the results of

    the transaction permanent but do not do so immediately. The participants log information

    to disk to ensure they can complete In phase 2 f all the participants agree to commit, thecoordinator logs that agreement and the outcome is decided. The recording of this

    agreement in the log ends in Phase 2, the coordinator informs each participant of the

    decision, and they permanently update their resources.

    14.How do you handle your own transaction ? - Connection Object has a method calledsetAutocommit(Boolean istrue)

    - Default is true. Set the Parameter to false , and begin your transaction15.

    What is the normal procedure followed by a java client to access the db.? - The

    database connection is created in 3 steps:

    1. Find a proper database URL

    2. Load the database driver

    3. Ask the Java DriverManager class to open a connection to your database

    In java code, the steps are realized in code as follows:

  • 8/11/2019 Java J2EE Faqs

    20/27

    Edited By Mahendra Kumar Shrivas [[email protected]]- +919098759901

    4. Create a properly formatted JDBR URL for your database. (See FAQ on JDBC URL for

    more information). A JDBC URL has the formjdbc:someSubProtocol://myDatabaseServer/theDatabaseName

    5.

    Class.forName("my.database.driver");6.

    Connection conn = DriverManager.getConnection("a.JDBC.URL",

    databaseLogin","databasePassword");

    16.What is a data source? - A DataSource class brings another level of abstraction than

    directly using a connection object. Data source can be referenced by JNDI. Data Source

    may point to RDBMS, file System , any DBMS etc.

    17.What are collection pools? What are the advantages? - A connection pool is a cache

    of database connections that is maintained in memory, so that the connections may be

    reused18.

    How do you get Column names only for a table (SQL Server)? Write the Query. -19. select name from syscolumns

    20.

    where id=(select id from sysobjects wherename='user_hdr')

    21. order by colid --user_hdr is the table name

    J2EE - Servlet Questions

    1. What is a servlet?

    Servlets are modules that extend request/response-oriented servers,such as Java-enabledweb servers. For example, a servlet might be responsible for taking data in an HTMLorder-entry form and applying the business logic used to update a companys order

    database. Servlets are to servers what applets are to browsers. Unlike applets, however,

    servlets have no graphical user interface.

    2. Whats the advantages using servlets over using CGI?Servlets provide a way to generate dynamic documents that is both easier to write and

    faster to run. Servlets also address the problem of doing server-side programming withplatform-specific APIs: they are developed with the Java Servlet API, a standard Java

    extension.

    3. What are the general advantages and selling points of Servlets?

    A servlet can handle multiple requests concurrently, and synchronize requests. Thisallows servlets to support systems such as online

    real-time conferencing. Servlets can forward requests to other servers and servlets. Thus

    servlets can be used to balance load among several servers that mirror the same content,and to partition a single logical service over several servers, according to task type or

    organizational boundaries.4.

    Which package provides interfaces and classes for writing servlets?javax

    5. Whats the Servlet Interface?The central abstraction in the Servlet API is the Servlet interface. All servlets implement

  • 8/11/2019 Java J2EE Faqs

    21/27

    Edited By Mahendra Kumar Shrivas [[email protected]]- +919098759901

    this interface, either directly or, more

    commonly, by extending a class that implements it such as HttpServlet.Servlets >Generic Servlet > HttpServlet > MyServlet.

    The Servlet interface declares, but does not implement, methods that manage the servletand its communications with clients. Servlet writers provide some or all of these methods

    when developing a servlet.

    6. When a servlet accepts a call from a client, it receives two objects. What are they?ServletRequest (which encapsulates the communication from the client to the server) and

    ServletResponse (which encapsulates the communication from the servlet back to the

    client). ServletRequest and ServletResponse are interfaces defined inside javax.servlet

    package.

    7. What information does ServletRequest allow access to?

    Information such as the names of the parameters passed in by the client, the protocol

    (scheme) being used by the client, and the names

    of the remote host that made the request and the server that received it. Also the inputstream, as ServletInputStream.Servlets use the input stream to get data from clients that

    use application protocols such as the HTTP POST and GET methods.

    8. What type of constraints can ServletResponse interface set on the client?It can set the content length and MIME type of the reply. It also provides an output

    stream, ServletOutputStream and a Writer through

    which the servlet can send the reply data.

    9. Explain servlet lifecycle?

    Each servlet has the same life cycle: first, the server loads and initializes the servlet

    (init()), then the servlet handles zero or more client requests (service()), after that the

    server removes the servlet (destroy()). Worth noting that the last step on some servers is

    done when they shut down.10.How does HTTP Servlet handle client requests?

    An HTTP Servlet handles client requests through its service method. The service method

    supports standard HTTP client requests by dispatching each request to a method designedto handle that request.

    J2EE - JSP Questions

    1. What is JSP? Describe its concept.JSP is a technology that combines HTML/XML

    markup languages and elements of Java programming Language to return dynamic

    content to the Web client, It is normally used to handle Presentation logic of a web

    application, although it may have business logic.2. What are the lifecycle phases of a JSP?

    JSP page looks like a HTML page but is a servlet. When presented with JSP page the JSP

    engine does the following 7 phases.

    1. Page translation: -page is parsed, and a java file which is a servlet is created.2.

    Page compilation: page is compiled into a class file

    3.

    Page loading : This class file is loaded.

    4.

    Create an instance :- Instance of servlet is created

  • 8/11/2019 Java J2EE Faqs

    22/27

    Edited By Mahendra Kumar Shrivas [[email protected]]- +919098759901

    5. jspInit() method is called

    6. _jspService is called to handle service calls7. _jspDestroy is called to destroy it when the servlet is not required.

    3.

    What is a translation unit?JSP page can include the contents of other HTML pages orother JSP files. This is done by using the include directive. When the JSP engine is

    presented with such a JSP page it is converted to one servlet class and this is called a

    translation unit, Things to remember in a translation unit is that page directives affect the

    whole unit, one variable declaration cannot occur in the same unit more than once, the

    standard action jsp:useBean cannot declare the same bean twice in one unit.

    4. How is JSP used in the MVC model?JSP is usually used for presentation in the MVC

    pattern (Model View Controller ) i.e. it plays the role of the view. The controller deals

    with calling the model and the business classes which in turn get the data, this data is thenpresented to the JSP for rendering on to the client.

    5. What are context initialization parameters?Context initialization parameters are

    specified by the in the web.xml file, these are initialization parameterfor the whole application and not specific to any servlet or JSP.

    6. What is a output comment?A comment that is sent to the client in the viewable pagesource. The JSP engine handles an output comment as un-interpreted HTML text,

    returning the comment in the HTML output sent to the client. You can see the comment

    by viewing the page source from your Web browser.

    7. What is a Hidden Comment?A comment that documents the JSP page but is not sent tothe client. The JSP engine ignores a hidden comment, and does not process any code

    within hidden comment tags. A hidden comment is not sent to the client, either in the

    displayed JSP page or the HTML page source. The hidden comment is useful when you

    want to hide or comment out part of your JSP page.

    8.

    What is a Expression?Expressions are act as place holders for language expression,expression is evaluated each time the page is accessed.

    9. What is a Declaration?It declares one or more variables or methods for use later in the

    JSP source file. A declaration must contain at least one complete declarative statement.You can declare any number of variables or methods within one declaration tag, as long

    as semicolons separate them. The declaration must be valid in the scripting language used

    in the JSP file.10.What is a Scriptlet?A scriptlet can contain any number of language statements, variable

    or method declarations, or expressions that are valid in the page scripting language.

    Within scriptlet tags, you can declare variables or methods to use later in the file, write

    expressions valid in the page scripting language, use any of the JSP implicit objects or

    any object declared with a .11.

    What are the implicit objects? List them.Certain objects that are available for the use

    in JSP documents without being declared first. These objects are parsed by the JSP

    engine and inserted into the generated servlet. The implicit objects are:

    o

    request

    o response

    o pageContext

    o sessiono

    application

  • 8/11/2019 Java J2EE Faqs

    23/27

    Edited By Mahendra Kumar Shrivas [[email protected]]- +919098759901

    o out

    o configo pageo

    exception12.

    Whats the difference between forward and sendRedirect?When you invoke a

    forward request, the request is sent to another resource on the server, without the client

    being informed that a different resource is going to process the request. This process

    occurs completely within the web container And then returns to the calling method.

    When a sendRedirect method is invoked, it causes the web container to return to the

    browser indicating that a new URL should be requested. Because the browser issues a

    completely new request any object that are stored as request attributes before the redirect

    occurs will be lost. This extra round trip a redirect is slower than forward.13.

    What are the different scope values for the ?The different scope

    values for are:

    o

    pageo

    request

    o sessiono application

    14.Why are JSP pages the preferred API for creating a web-based client program?Because no plug-ins or security policy files are needed on the client systems(applet does).

    Also, JSP pages enable cleaner and more module application design because they providea way to separate applications programming from web page design. This means

    personnel involved in web page design do not need to understand Java programming

    language syntax to do their jobs.

    15.Is JSP technology extensible?Yes, it is. JSP technology is extensible through the

    development of custom actions, or tags, which are encapsulated in tag libraries.16.What is difference between custom JSP tags and beans?Custom JSP tag is a tag you

    defined. You define how a tag, its attributes and its body are interpreted, and then group

    your tags into collections called tag libraries that can be used in any number of JSP files.Custom tags and beans accomplish the same goals encapsulating complex behavior into

    simple and accessible forms. There are several differences:

    o

    Custom tags can manipulate JSP content; beans cannot.o

    Complex operations can be reduced to a significantly simpler form with custom

    tags than with beans.

    o Custom tags require quite a bit more work to set up than do beans.

    o Custom tags usually define relatively self-contained behavior, whereas beans are

    often defined in one servlet and used in a different servlet or JSP page.o

    Custom tags are available only in JSP 1.1 and later, but beans can be used in all

    JSP 1.x versions.

    17.What is Struts?- A Web page development framework. Struts combines Java Servlets,Java Server Pages, custom tags, and message resources into a unified framework. It is a

  • 8/11/2019 Java J2EE Faqs

    24/27

    Edited By Mahendra Kumar Shrivas [[email protected]]- +919098759901

    cooperative, synergistic platform, suitable for development teams, independent

    developers, and everyone between.18.How is the MVC design pattern used in Struts framework?- In the MVC design

    pattern, application flow is mediated by a central Controller. The Controller delegatesrequests to an appropriate handler. The handlers are tied to a Model, and each handler

    acts as an adapter between the request and the Model. The Model represents, or

    encapsulates, an applications business logic or state. Control is usually then forwarded

    back through the Controller to the appropriate View. The forwarding can be determined

    by consulting a set of mappings, usually loaded from a database or configuration file.

    This provides a loose coupling between the View and Model, which can make an

    application significantly easier to create and maintain. Controller: Servlet controller

    which supplied by Struts itself; View: what you can see on the screen, a JSP page andpresentation components; Model: System state and a business logic JavaBeans.

    J2EE Questions

    1. What makes J2EE suitable for distributed multitier Applications?

    - The J2EE platform uses a multitier distributed application model. Application logic is

    divided into components according to function, and the various application components

    that make up a J2EE application are installed on different machines depending on the tier

    in the multitiered J2EE environment to which the application component belongs. The

    J2EE application parts are:o

    Client-tier components run on the client machine.o

    Web-tier components run on the J2EE server.o

    Business-tier components run on the J2EE server.

    o

    Enterprise information system (EIS)-tier software runs on the EIS server.2.

    What is J2EE?- J2EE is an environment for developing and deploying enterprise

    applications. The J2EE platform consists of a set of services, application programming

    interfaces (APIs), and protocols that provide the functionality for developing multitiered,

    web-based applications.

    3. What are the components of J2EE application?- A J2EE component is a self-contained functional software unit that is assembled into a

    J2EE application with its related classes and files and communicates with othercomponents. The J2EE specification defines the following J2EE components:

    1.

    Application clients and applets are client components.

    2.

    Java Servlet and JavaServer Pages technology components are web components.

    3.

    Enterprise JavaBeans components (enterprise beans) are business components.4. Resource adapter components provided by EIS and tool vendors.

    4. What do Enterprise JavaBeans components contain?- Enterprise JavaBeans

    components contains Business code, which is logic

    that solves or meets the needs of a particular business domain such as banking, retail, orfinance, is handled by enterprise beans running in the business tier. All the business code

    is contained inside an Enterprise Bean which receives data from client programs,

    processes it (if necessary), and sends it to the enterprise information system tier for

  • 8/11/2019 Java J2EE Faqs

    25/27

    Edited By Mahendra Kumar Shrivas [[email protected]]- +919098759901

    storage. An enterprise bean also retrieves data from storage, processes it (if necessary),

    and sends it back to the client program.5. Is J2EE application only a web-based?- No, It depends on type of application that

    client wants. A J2EE application can be web-based or non-web-based. if an applicationclient executes on the client machine, it is a non-web-based J2EE application. The J2EE

    application can provide a way for users to handle tasks such as J2EE system or

    application administration. It typically has a graphical user interface created from Swing

    or AWT APIs, or a command-line interface. When user request, it can open an HTTP

    connection to establish communication with a servlet running in the web tier.

    6. Are JavaBeans J2EE components?- No. JavaBeans components are not considered

    J2EE components by the J2EE specification. They are written to manage the data flow

    between an application client or applet and components running on the J2EE server orbetween server components and a database. JavaBeans components written for the J2EE

    platform have instance variables and get and set methods for accessing the data in the

    instance variables. JavaBeans components used in this way are typically simple in designand implementation, but should conform to the naming and design conventions outlined

    in the JavaBeans component architecture.7. Is HTML page a web component?- No. Static HTML pages and applets are bundled

    with web components during application assembly, but are not considered web

    components by the J2EE specification. Even the server-side utility classes are not

    considered web components, either.8.

    What can be considered as a web component?- J2EE Web components can be either

    servlets or JSP pages. Servlets are Java programming language classes that dynamically

    process requests and construct responses. JSP pages are text-based documents that

    execute as servlets but allow a more natural approach to creating static content.

    9.

    What is the container?- Containers are the interface between a component and the low-level platform specific functionality that supports the component. Before a Web,

    enterprise bean, or application client component can be executed, it must be assembled

    into a J2EE application and deployed into its container.10.

    What are container services?- A container is a runtime support of a system-level

    entity. Containers provide components with services such as lifecycle management,

    security, deployment, and threading.11.What is the web container?- Servlet and JSP containers are collectively referred to as

    Web containers. It manages the execution of JSP page and servlet components for J2EE

    applications. Web components and their container run on the J2EE server.

    12.What is Enterprise JavaBeans (EJB) container?- It manages the execution of

    enterprise beans for J2EE applications.Enterprise beans and their container run on the J2EE server.

    13.What is Applet container?- IManages the execution of applets. Consists of a Web

    browser and Java Plugin running on the client together.

    14.How do we package J2EE components?- J2EE components are packaged separately

    and bundled into a J2EE application for deployment. Each component, its related files

    such as GIF and HTML files or server-side utility classes, and a deployment descriptor

    are assembled into a module and added to the J2EE application. A J2EE application is

    composed of one or more enterprise bean,Web, or application client component modules.

  • 8/11/2019 Java J2EE Faqs

    26/27

    Edited By Mahendra Kumar Shrivas [[email protected]]- +919098759901

    The final enterprise solution can use one J2EE application or be made up of two or more

    J2EE applications, depending on design requirements. A J2EE application and each of itsmodules has its own deployment descriptor. A deployment descriptor is an XML

    document with an .xml extension that describes a components deployment settings.15.

    What is a thin client?- A thin client is a lightweight interface to the application that

    does not have such operations like query databases, execute complex business rules, or

    connect to legacy applications.

    16.What are types of J2EE clients?- Following are the types of J2EE clients:

    o Applets

    o Application clients

    o Java Web Start-enabled rich clients, powered by Java Web Start technology.o

    Wireless clients, based on Mobile Information Device Profile (MIDP) technology.17.

    What is deployment descriptor?- A deployment descriptor is an Extensible Markup

    Language (XML) text-based file with an .xml extension that describes a components

    deployment settings. A J2EE application and each of its modules has its own deploymentdescriptor. For example, an enterprise bean module deployment descriptor declares

    transaction attributes and security authorizationsfor an enterprise bean. Because deployment descriptor information is declarative, it can

    be changed without modifying the bean source code. At run time, the J2EE server reads

    the deployment descriptor and acts upon the component accordingly.

    18.What is the EAR file?- An EAR file is a standard JAR file with an .ear extension,named from Enterprise ARchive file. A J2EE application with all of its modules is

    delivered in EAR file.

    19.What is JTA and JTS?- JTA is the abbreviation for the Java Transaction API. JTS is

    the abbreviation for the Jave Transaction Service. JTA provides a standard interface and

    allows you to demarcate transactions in a manner that is independent of the transactionmanager implementation. The J2EE SDK implements the transaction manager with JTS.

    But your code doesnt call the JTS methods directly. Instead, it invokes the JTA methods,

    which then call the lower-level JTS routines. Therefore, JTA is a high level transactioninterface that your application uses to control transaction. and JTS is a low level

    transaction interface and ejb uses behind the scenes (client code doesnt directly interact

    with JTS. It is based on object transaction service(OTS) which is part of CORBA.20.What is JAXP?- JAXP stands for Java API for XML. XML is a language for

    representing and describing text-based data which can be read and handled by any

    program or tool that uses XML APIs. It provides standard services to determine the type

    of an arbitrary piece of data, encapsulate access to it, discover the operations available on

    it, and create the appropriate JavaBeans component to perform those operations.21.

    What is J2EE Connector?- The J2EE Connector API is used by J2EE tools vendors

    and system integrators to create resource adapters that support access to enterprise

    information systems that can be plugged into any J2EE product. Each type of database or

    EIS has a different resource adapter. Note: A resource adapter is a software component

    that allows J2EE application components to access and interact with the underlying

    resource manager. Because a resource adapter is specific to its resource manager, there is

    typically a different resource adapter for each type of database or enterprise information

    system.

  • 8/11/2019 Java J2EE Faqs

    27/27

    Edited By Mahendra Kumar Shrivas [[email protected]]- +919098759901

    22.What is JAAP?- The Java Authentication and Authorization Service (JAAS) provides a

    way for a J2EE application to authenticate and authorize a specific user or group of usersto run it. It is a standard Pluggable Authentication Module (PAM) framework that

    extends the Java 2 platform security architecture to support user-based authorization.23.

    What is Java Naming and Directory Service?- The JNDI provides naming and

    directory functionality. It provides applications with methods for performing standard

    directory operations, such as associating attributes with objects and searching for objects

    using their attributes. Using JNDI, a J2EE application can store and retrieve any type of

    named Java object. Because JNDI is independent of any specific implementations,

    applications can use JNDI to access multiple naming and directory services, including

    existing naming and

    directory services such as LDAP, NDS, DNS, and NIS.

    References

    http://www.oracle.comhttp://www.naukri.com

    http://www.timesjob.comhttp://www.techinterviews.com

    Thanks to Mr. Sachin Rastogi for his great contribution.