600+ Advance Java Interview Questions And Answers

Spread the love

Advance Java Interview Questions

Question 1. What Is A Transient Variable?

A transient variable is a variable that will not be serialized.

Question 2. Which Containers Use A Border Layout As Their Default Layout?

The Window, Frame and Dialog courses use a border format as their default format.

Question 3. Why Do Threads Block On I/o?

Threads block on I/O (that’s enters the ready state) in order that different threads could execute whereas the I/O Operation is carried out.

Question 4. How Are Observer And Observable Used?

Objects that subclass the Observable class keep an inventory of observers. When an Observable object is up to date it invokes the replace() methodology of every of its observers to inform the observers that it has modified state. The Observer interface is applied by objects that observe Observable objects.

Question 5. What Is Synchronization And Why Is It Important?

With respect to multithreading, synchronization is the potential to regulate the entry of a number of threads to shared assets. Without synchronization, it’s doable for one thread to switch a shared object whereas one other thread is within the means of utilizing or updating that object’s worth. This usually results in important errors.

Question 6. Can A Lock Be Acquired On A Class?

Yes, a lock may be acquired on a category. This lock is acquired on the category’s Class object..

Question 7. What’s New With The Stop(), Suspend() And Resume() Methods In Jdk 1.2?

The cease(), droop() and resume() strategies have been deprecated in JDK 1.2.

Question 8. Is Null A Keyword?

The null isn’t a key phrase.

Question 9. What Is The Preferred Size Of A Component?

The most well-liked dimension of a part is the minimal part dimension that can enable the part to show usually.

Question 10. What Method Is Used To Specify A Container’s Layout?

The setLayout() methodology is used to specify a container’s format.

Question 11. Which Containers Use A Flowlayout As Their Default Layout?

The Panel and Applet courses use the MovementLayout as their default format.

Question 12. What State Does A Thread Enter When It Terminates Its Processing?

When a thread terminates its processing, it enters the lifeless state.

Question 13. What Is The Collections Api?

The Collections API is a set of courses and interfaces that assist operations on collections of objects.

Question 14. Which Characters May Be Used As The Second Character Of An Identifier, But Not As The First Character Of An Identifier?

The digits zero via 9 will not be used as the primary character of an identifier however they might be used after the primary character of an identifier.

Question 15. What Is The List Interface?

The List interface gives assist for ordered collections of objects.

Question 16. How Does Java Handle Integer Overflows And Underflows?

It makes use of these low order bytes of the consequence that may match into the dimensions of the sort allowed by the operation.

Question 17. What Is The Vector Class?

The Vector class gives the potential to implement a growable array of objects.

Question 18. What Modifiers May Be Used With An Inner Class That Is A Member Of An Outer Class?

A (non-local) inside class could also be declared as public, protected, non-public, static, ultimate, or summary.

Question 19. What Is An Iterator Interface?

The Iterator interface is used to step via the weather of a Collection.

Question 20. What Is The Difference Between The >> And >>> Operators?

The >> operator carries the signal bit when shifting proper. The >>> zero-fills bits which have been shifted out.

Question 21. Which Method Of The Component Class Is Used To Set The Position And Size Of A Component?

setBounds() methodology is used to set the place and dimension of a part.

Question 22. What Is The Difference Between Yielding And Sleeping?

When a process invokes its yield() methodology, it returns to the prepared state. When a process invokes its sleep() methodology, it returns to the ready state.

Question 23. Which Java.util Classes And Interfaces Support Event Handling?

The EventObject class and the EventListener interface assist occasion processing.

Question 24. Is Sizeof A Keyword?

The sizeof operator isn’t a key phrase.

Question 25. What Are Wrapped Classes?

Wrapped courses are courses that enable primitive sorts to be accessed as objects.

Question 26. Does Garbage Collection Guarantee That A Program Will Not Run Out Of Memory?

Garbage assortment doesn’t assure {that a} program is not going to run out of reminiscence. It is feasible for packages to make use of up reminiscence assets quicker than they’re rubbish collected. It can also be doable for packages to create objects that aren’t topic to rubbish assortment.

Question 27. What Restrictions Are Placed On The Location Of A Package Statement Within A Source Code File?

A bundle assertion should seem as the primary line in a supply code file (excluding clean strains and feedback).

Question 28. Can An Object’s Finalize() Method Be Invoked While It Is Reachable?

An object’s finalize() methodology can’t be invoked by the rubbish collector whereas the item remains to be reachable. However, an object’s finalize() methodology could also be invoked by different objects.

Question 29. What Is The Immediate Superclass Of The Applet Class?

Panel.

Question 30. What Is The Difference Between Preemptive Scheduling And Time Slicing?

Under preemptive scheduling, the best precedence process executes till it enters the ready or lifeless states or a better precedence process comes into existence. Under time slicing, a process executes for a predefined slice of time after which reenters the pool of prepared duties.
The scheduler then determines which process ought to execute subsequent, based mostly on precedence and different elements.

Question 31. Name Three Component Subclasses That Support Painting.

The Canvas, Frame, Panel, and Applet courses assist portray.

Question 32. What Value Does Readline() Return When It Has Reached The End Of A File?

The readLine() methodology returns null when it has reached the tip of a file.

Question 33. What Is The Immediate Superclass Of The Dialog Class?

Window.

Question 34. What Is Clipping?

Clipping is the method of confining paint operations to a restricted space or form.

Question 35. What Is A Native Method?

A local methodology is a technique that’s applied in a language apart from Java.

Question 36. Can A For Statement Loop Indefinitely?

Yes, a for assertion can loop indefinitely. For instance, take into account the next:
for(;;) ;

Question 37. What Are Order Of Precedence And Associativity, And How Are They Used?

Order of priority determines the order through which operators are evaluated in expressions.

Associatity determines whether or not an expression is evaluated left-to-right or right-to-left.

Question 38. When A Thread Blocks On I/o, What State Does It Enter?

A thread enters the ready state when it blocks on I/O.

Question 39. To What Value Is A Variable Of The String Type Automatically Initialized?

The default worth of an String kind is null.

Question 40. What Is The Catch Or Declare Rule For Method Declarations?

If a checked exception could also be thrown throughout the physique of a technique, the tactic should both catch the exception or declare it in its throws clause.

Question 41. What Is The Difference Between A Menuitem And A Checkboxmenuitem?

The CheckboxMenuItem class extends the MenuItem class to assist a menu merchandise that could be checked or unchecked.

Question 42. What Is A Task’s Priority And How Is It Used In Scheduling?

A process’s precedence is an integer worth that identifies the relative order through which it needs to be executed with respect to different duties. The scheduler makes an attempt to schedule larger precedence duties earlier than decrease precedence duties.

Question 43. What Class Is The Top Of The Awt Event Hierarchy?

The java.awt.AWTEvent class is the highest-level class within the AWT event-class hierarchy.

Question 44. When A Thread Is Created And Started, What Is Its Initial State?

A thread is within the prepared state after it has been created and began.

Question 45. Can An Anonymous Class Be Declared As Implementing An Interface And Extending A Class?

An nameless class could implement an interface or lengthen a superclass, however will not be declared to do each.

Question 46. What Is The Immediate Superclass Of Menu?

MenuItem.

Question 47. What Is The Purpose Of Finalization?

The goal of finalization is to present an unreachable object the chance to carry out any cleanup processing earlier than the item is rubbish collected.

Question 48. Which Class Is The Immediate Superclass Of The Menucomponent Class?

Object.

Question 49. What Invokes A Thread’s Run() Method?

After a thread is began, through its begin() methodology or that of the Thread class, the JVM invokes the thread’s run() methodology when the thread is initially executed.

Question 50. What Is The Difference Between The Boolean & Operator And The && Operator?

If an expression involving the Boolean & operator is evaluated, each operands are evaluated. Then the & operator is utilized to the operand. When an expression involving the && operator is evaluated, the primary operand is evaluated.

If the primary operand returns a price of true then the second operand is evaluated. The && operator is then utilized to the primary and second operands. If the primary operand evaluates to false, the analysis of the second operand is skipped.

Question 51. Name Three Subclasses Of The Component Class.

Box.Filler, Button, Canvas, Checkbox, Choice, Container, Label, List, Scrollbar, or Textual contentComponent.

Question 52. What Is The Gregoriancalendar Class?

The GregorianCalendar class gives assist for conventional Western calendars.

Question 53. Which Container Method Is Used To Cause A Container To Be Laid Out And Redisplayed?

validate() methodology is used to trigger a container to be laid out and redisplayed.

Question 54. What Is The Purpose Of The Runtime Class?

The goal of the Runtime class is to offer entry to the Java runtime system.

Question 55. How Many Times May An Object’s Finalize() Method Be Invoked By The Garbage Collector?

An object’s finalize() methodology could solely be invoked as soon as by the rubbish collector.

Question 56. What Is The Purpose Of The Finally Clause Of A Try-catch-finally Statement?

The lastly clause is used to offer the potential to execute code irrespective of whether or not or not an exception is thrown or caught.

Question 57. What Is The Argument Type Of A Program’s Main() Method?

A program’s important() methodology takes an argument of the String[] kind.

Question 58. Which Java Operator Is Right Associative?

The = operator is correct associative.

Question 59. Can A Double Value Be Cast To A Byte?

Yes, a double worth may be forged to a byte.

Question 60. What Must A Class Do To Implement An Interface?

It should present the entire strategies within the interface and determine the interface in its implements clause.

Question 61. What Method Is Invoked To Cause An Object To Begin Executing As A Separate Thread?

The begin() methodology of the Thread class is invoked to trigger an object to start executing as a separate thread.

Question 62. Name Two Subclasses Of The Textcomponent Class.

TextField and Textual contentArea.

Question 63. Which Containers May Have A Menubar?

Frame.

Question 64. How Are Commas Used In The Intialization And Iteration Parts Of A For Statement?

Commas are used to separate a number of statements throughout the initialization and iteration components of a for assertion.

Question 65. What Is The Purpose Of The Wait(), Notify(), And Notifyall() Methods?

The wait(), notify(), and notifyAll() strategies are used to offer an environment friendly manner for threads to attend for a shared useful resource. When a thread executes an object’s wait() methodology, it enters the ready state. It solely enters the prepared state after one other thread invokes the item’s notify() or notifyAll() strategies..

Question 66. What Is An Abstract Method?

An summary methodology is a technique whose implementation is deferred to a subclass.

Question 67. How Are Java Source Code Files Named?

A Java supply code file takes the identify of a public class or interface that’s outlined throughout the file. A supply code file could include at most one public class or interface. If a public class or interface is outlined inside a supply code file, then the supply code file should take the identify of the general public class or interface.

If no public class or interface is outlined inside a supply code file, then the file should tackle a reputation that’s totally different than its courses and interfaces. Source code information use the .java extension.

Question 68. What Is The Relationship Between The Canvas Class And The Graphics Class?

A Canvas object gives entry to a Graphics object through its paint() methodology.

Question 69. What Are The High-level Thread States?

The high-level thread states are prepared, operating, ready, and lifeless.

Question 70. What Value Does Read() Return When It Has Reached The End Of A File?

The learn() methodology returns -1 when it has reached the tip of a file.

Question 71. Can A Byte Object Be Cast To A Double Value?

No. An object can’t be forged to a primitive worth.

Question 72. What Is The Difference Between A Static And A Non-static Inner Class?

A non-static inside class could have object cases which can be related to cases of the category’s outer class.

A static inside class doesn’t have any object cases.

Question 73. What Is The Difference Between The String And Stringbuffer Classes?

String objects are constants. StringBuffer objects will not be constants.

Question 74. If A Variable Is Declared As Private, Where May The Variable Be Accessed?

A non-public variable could solely be accessed throughout the class wherein it’s declared.

Question 75. What Is An Object’s Lock And Which Object’s Have Locks?

An object’s lock is a mechanism that’s utilized by a number of threads to acquire synchronized entry to the thing. A thread could execute a synchronized technique of an object solely after it has acquired the thing’s lock.

All objects and lessons have locks. A category’s lock is acquired on the category’s Class object.

Question 76. What Is The Dictionary Class?

The Dictionary class gives the aptitude to retailer key-value pairs.

Question 77. How Are The Elements Of A Borderlayout Organized?

The parts of a BorderLayout are organized on the borders (North, South, East, and West) and the middle of a container.

Question 78. What Is The % Operator?

It is known as the modulo or the rest operator. It returns the rest of dividing the primary operand by the second operand.

Question 79. When Can An Object Reference Be Cast To An Interface Reference?

An object reference be forged to an interface reference when the thing implements the referenced interface.

Question 80. What Is The Difference Between A Window And A Frame?

The Frame class extends Window to outline a major utility window that may have a menu bar.

Question 81. Which Class Is Extended By All Other Classes?

The Object class is prolonged by all different lessons.

Question 82. Can An Object Be Garbage Collected While It Is Still Reachable?

A reachable object can’t be rubbish collected. Only unreachable objects could also be rubbish collected..

Question 83. Is The Ternary Operator Written X : Y ? Z Or X ? Y : Z ?

It is written x ? y : z.

Question 84. What Is The Difference Between The Font And Fontmetrics Classes?

The FontMetrics class is used to outline implementation-specific properties, comparable to ascent and descent, of a Font object.

Question 85. How Is Rounding Performed Under Integer Division?

The fractional a part of the result’s truncated. This is named rounding towards zero.

Question 86. What Happens When A Thread Cannot Acquire A Lock On An Object?

If a thread makes an attempt to execute a synchronized technique or synchronized assertion and is unable to amass an object’s lock, it enters the ready state till the lock turns into obtainable.

Question 87. What Is The Difference Between The Reader/author Class Hierarchy And The Inputstream/outputstream Class Hierarchy?

The Reader/Writer class hierarchy is character-oriented, and the InputStream/OutputStream class hierarchy is byte-oriented.

Question 88. What Classes Of Exceptions May Be Caught By A Catch Clause?

A catch clause can catch any exception that could be assigned to the Throwable sort. This consists of the Error and Exception sorts.

Question 89. If A Class Is Declared Without Any Access Modifiers, Where May The Class Be Accessed?

A category that’s declared with none entry modifiers is alleged to have bundle entry. This implies that the category can solely be accessed by different lessons and interfaces which are outlined throughout the similar bundle.

Question 90. What Is The Simpletimezone Class?

The SimpleTimeZone class gives assist for a Gregorian calendar.

Question 91. What Is The Map Interface?

The Map interface replaces the JDK 1.1 Dictionary class and is used affiliate keys with values.

Question 92. Does A Class Inherit The Constructors Of Its Superclass?

A category doesn’t inherit constructors from any of its superclasses.

Question 93. For Which Statements Does It Make Sense To Use A Label?

The solely statements for which it is sensible to make use of a label are these statements that may enclose a break or proceed assertion.

Question 94. What Is The Purpose Of The System Class?

The objective of the System class is to supply entry to system assets.

Question 95. Which Textcomponent Method Is Used To Set A Textcomponent To The Read-only State?

setEditable().

Question 96. How Are The Elements Of A Cardlayout Organized?

The parts of a CardLayout are stacked, one on prime of the opposite, like a deck of playing cards.

Question 97. Is &&= A Valid Java Operator?

No. It isn’t a legitimate java operator.

Question 98. Name The Eight Primitive Java Types.

The eight primitive sorts are byte, char, quick, int, lengthy, float, double, and boolean.

Question 99. Which Class Should You Use To Obtain Design Information About An Object?

The Class class is used to acquire details about an object’s design.

Question 100. What Is The Relationship Between Clipping And Repainting?

When a window is repainted by the AWT portray thread, it units the clipping areas to the realm of the window that requires repainting.

Question 101. Is “abc” A Primitive Value?

The String literal “abc” isn’t a primitive worth. It is a String object.

Question 102. What Is The Relationship Between An Event-listener Interface And An Event-adapter Class?

An event-listener interface defines the strategies that have to be applied by an occasion handler for a selected sort of occasion.

An occasion adapter gives a default implementation of an event-listener interface.

Question 103. What Restrictions Are Placed On The Values Of Each Case Of A Switch Statement?

During compilation, the values of every case of a swap assertion should consider to a worth that may be promoted to an int worth.

Question 104. What Modifiers May Be Used With An Interface Declaration?

An interface could also be declared as public or summary.

Question 105. Is A Class A Subclass Of Itself?

A category is a subclass of itself.

Question 106. What Is The Highest-level Event Class Of The Event-delegation Model?

The java.util.EventObject class is the highest-level class within the event-delegation class hierarchy.

Question 107. What Event Results From The Clicking Of A Button?

The MotionEvent occasion is generated as the results of the click of a button.

Question 108. How Can A Gui Component Handle Its Own Events?

A part can deal with its personal occasions by implementing the required event-listener interface and including itself as its personal occasion listener.

Question 109. How Are The Elements Of A Gridbaglayout Organized?

The parts of a GridBagLayout are organized in response to a grid. However, the weather are of various sizes and should occupy multiple row or column of the grid. In addition, the rows and columns could have totally different sizes.

Question 110. What Advantage Do Java’s Layout Managers Provide Over Traditional Windowing Systems?

Java makes use of structure managers to put out elements in a constant method throughout all windowing platforms. Since Java’s structure managers aren’t tied to absolute sizing and positioning, they’re able to accomodate platform-specific variations amongst windowing programs.

Question 111. What Is The Collection Interface?

The Collection interface gives assist for the implementation of a mathematical bag – an unordered assortment of objects which will include duplicates.

Question 112. What Modifiers Can Be Used With A Local Inner Class?

A neighborhood internal class could also be remaining or summary.

Question 113. What Is The Difference Between Static And Non-static Variables?

A static variable is related to the category as a complete relatively than with particular situations of a category.

Non-static variables tackle distinctive values with every object occasion.

Question 114. What Is The Difference Between The Paint() And Repaint() Methods?

The paint() technique helps portray by way of a Graphics object. The repaint() technique is used to trigger paint() to be invoked by the AWT portray thread.

Question 115. What Is The Purpose Of The File Class?

The File class is used to create objects that present entry to the recordsdata and directories of a neighborhood file system.

Question 116. Can An Exception Be Rethrown?

Yes, an exception may be rethrown.

Question 117. Which Math Method Is Used To Calculate The Absolute Value Of A Number?

The abs() technique is used to calculate absolute values.

Question 118. How Does Multithreading Take Place On A Computer With A Single Cpu?

The working system’s process scheduler allocates execution time to a number of duties. By shortly switching between executing duties, it creates the impression that duties execute sequentially.

Question 119. When Does The Compiler Supply A Default Constructor For A Class?

The compiler provides a default constructor for a category if no different constructors are offered.

Question 120. When Is The Finally Clause Of A Try-catch-finally Statement Executed?

The lastly clause of the try-catch-finally assertion is at all times executed except the thread of execution terminates or an exception happens throughout the execution of the lastly clause.

Question 121. Which Class Is The Immediate Superclass Of The Container Class?

Component.

Question 122. If A Method Is Declared As Protected, Where May The Method Be Accessed?

A protected technique could solely be accessed by lessons or interfaces of the identical bundle or by subclasses of the category wherein it’s declared.

Question 123. How Can The Checkbox Class Be Used To Create A Radio Button?

By associating Checkbox objects with a CheckboxGroup.

Question 124. Which Non-unicode Letter Characters May Be Used As The First Character Of An Identifier?

The non-Unicode letter characters $ and _ could seem as the primary character of an identifier

Question 125. What Restrictions Are Placed On Method Overloading?

Two strategies could not have the identical title and argument listing however totally different return sorts.

Question 126. What Happens When You Invoke A Thread’s Interrupt Method While It Is Sleeping Or Waiting?

When a process’s interrupt() technique is executed, the duty enters the prepared state. The subsequent time the duty enters the working state, an InterruptedException is thrown.

Question 127. What Is Casting?

There are two forms of casting, casting between primitive numeric sorts and casting between object references.

Casting between numeric sorts is used to transform bigger values, comparable to double values, to smaller values, comparable to byte values.

Casting between object references is used to check with an object by a appropriate class, interface, or array sort reference.

Question 128. What Is The Return Type Of A Program’s Main() Method?

A program’s major() technique has a void return sort.

Question 129. Name Four Container Classes.

Window, Frame, Dialog, FileDialog, Panel, Applet, or ScrollPane.

Question 130. What Is The Difference Between A Choice And A List?

A Choice is displayed in a compact type that requires you to drag it right down to see the listing of obtainable decisions. Only one merchandise could also be chosen from a Choice.

A List could also be displayed in such a means that a number of List objects are seen. A List helps the collection of a number of List objects.

Question 131. What Class Of Exceptions Are Generated By The Java Run-time System?

The Java runtime system generates RuntimeException and Error exceptions.

Question 132. What Class Allows You To Read Objects Directly From A Stream?

The ObjectInputStream class helps the studying of objects from enter streams.

Question 133. What Is The Difference Between A Field Variable And A Local Variable?

A subject variable is a variable that’s declared as a member of a category.

A neighborhood variable is a variable that’s declared native to a technique.

Question 134. Under What Conditions Is An Object’s Finalize() Method Invoked By The Garbage Collector?

The rubbish collector invokes an object’s finalize() technique when it detects that the thing has change into unreachable.

Question 135. What Is The Relationship Between A Method’s Throws Clause And The Exceptions That Can Be Thrown During The Method’s Execution?

A technique’s throws clause should declare any checked exceptions that aren’t caught throughout the physique of the strategy.

Question 136. What Is The Difference Between The Jdk 1.02 Event Model And The Event-delegation Model Introduced With Jdk 1.1?

The JDK 1.02 occasion mannequin makes use of an occasion inheritance or effervescent strategy. In this mannequin, elements are required to deal with their very own occasions. If they don’t deal with a selected occasion, the occasion is inherited by (or bubbled as much as) the part’s container. The container then both handles the occasion or it’s bubbled as much as its container and so forth, till the highest-level container has been tried.

In the event-delegation mannequin, particular objects are designated as occasion handlers for GUI elements. These objects implement event-listener interfaces. The event-delegation mannequin is extra environment friendly than the event-inheritance mannequin as a result of it eliminates the processing required to assist the effervescent of unhandled occasions.

Question 137. How Is It Possible For Two String Objects With Identical Values Not To Be Equal Under The == Operator?

The == operator compares two objects to find out if they’re the identical object in reminiscence. It is feasible for 2 String objects to have the identical worth, however positioned detached areas of reminiscence.

Question 138. Why Are The Methods Of The Math Class Static?

So they are often invoked as if they’re a mathematical code library.

Question 139. What Checkbox Method Allows You To Tell If A Checkbox Is Checked?

getState().

Question 140. What State Is A Thread In When It Is Executing?

An executing thread is within the working state.

Question 141. What Are The Legal Operands Of The Instanceof Operator?

The left operand is an object reference or null worth and the correct operand is a category, interface, or array sort.

Question 142. What An I/o Filter?

An I/O filter is an object that reads from one stream and writes to a different, normally altering the information in a roundabout way as it’s handed from one stream to a different.

Question 143. If An Object Is Garbage Collected, Can It Become Reachable Again?

Once an object is rubbish collected, it ceases to exist. It can not change into reachable once more.

Question 144. What Is The Set Interface?

The Set interface gives strategies for accessing the weather of a finite mathematical set. Sets don’t enable duplicate parts.

Question 145. What Classes Of Exceptions May Be Thrown By A Throw Statement?

A throw assertion could throw any expression that could be assigned to the Throwable sort.

Question 146. What Are E And Pi?

E is the bottom of the pure logarithm and PI is mathematical worth pi.

Question 147. Are True And False Keywords?

The values true and false will not be key phrases.

Question 148. What Is A Void Return Type?

A void return sort signifies {that a} technique doesn’t return a worth.

Question 149. What Is The Purpose Of The Enableevents() Method?

The allowEvents() technique is used to allow an occasion for a selected object. Normally, an occasion is enabled when a listener is added to an object for a selected occasion.

The allowEvents() technique is utilized by objects that deal with occasions by overriding their event-dispatch strategies.

Question 150. What Is The Difference Between The File And Randomaccessfile Classes?

The File class encapsulates the recordsdata and directories of the native file system.

The RandomAccessFile class gives the strategies wanted to immediately entry knowledge contained in any a part of a file.

Question 151. What Happens When You Add A Double Value To A String?

The result’s a String object.

Question 152. What Is Your Platform’s Default Character Encoding?

If you might be working Java on English Windows platforms, it’s most likely Cp1252. If you might be working Java on English Solaris platforms, it’s almost certainly 8859_1.

Question 153. Which Package Is Always Imported By Default?

The java.lang bundle is at all times imported by default.

Question 154. What Interface Must An Object Implement Before It Can Be Written To A Stream As An Object?

An object should implement the Serializable or Externalizable interface earlier than it may be written to a stream as an object.

Question 155. How Are This And Super Used?

that is used to check with the present object occasion.

tremendous is used to check with the variables and strategies of the superclass of the present object occasion.

Question 156. What Is A Compilation Unit?

A compilation unit is a Java supply code file.

Question 157. What Interface Is Extended By Awt Event Listeners?

All AWT occasion listeners prolong the java.util.EventListener interface.

Question 158. What Restrictions Are Placed On Method Overriding?

Overridden strategies will need to have the identical title, argument listing, and return sort.

The overriding technique could not restrict the entry of the strategy it overrides.

The overriding technique could not throw any exceptions that will not be thrown by the overridden technique.

Question 159. How Can A Dead Thread Be Restarted?

A lifeless thread can’t be restarted.

Question 160. What Happens If An Exception Is Not Caught?

An uncaught exception ends in the uncaughtException() technique of the thread’s ThreadGroup being invoked, which finally ends in the termination of this system wherein it’s thrown.

Question 161. What Is A Layout Manager?

A structure supervisor is an object that’s used to prepare elements in a container.

Question 162. Which Arithmetic Operations Can Result In The Throwing Of An Arithmeticexception?

Integer / and % can lead to the throwing of an ArithmeticException.

Question 163. What Are Three Ways In Which A Thread Can Enter The Waiting State?

A thread can enter the ready state by invoking its sleep() technique, by blocking on I/O, by unsuccessfully trying to amass an object’s lock, or by invoking an object’s wait() technique. It can even enter the ready state by invoking its (deprecated) droop() technique.

Question 164. Can An Abstract Class Be Final?

An summary class is probably not declared as remaining.

Question 165. What Is The Resourcebundle Class?

The ResourceBundle class is used to retailer locale-specific assets that may be loaded by a program to tailor this system’s look to the actual locale by which it’s being run.

Question 166. What Happens If A Try-catch-finally Statement Does Not Have A Catch Clause To Handle An Exception That Is Thrown Within The Body Of The Try Statement?

The exception propagates as much as the subsequent larger stage try-catch assertion (if any) or ends in this system’s termination.

Question 167. What Is Numeric Promotion?

Numeric promotion is the conversion of a smaller numeric kind to a bigger numeric kind, in order that integer and floating-point operations could happen. In numerical promotion, byte, char, and quick values are transformed to int values. The int values are additionally transformed to lengthy values, if mandatory. The lengthy and float values are transformed to double values, as required.

Question 168. What Is The Difference Between A Scrollbar And A Scrollpane?

A Scrollbar is a Component, however not a Container. A ScrollPane is a Container.

A ScrollPane handles its personal occasions and performs its personal scrolling.

Question 169. What Is The Difference Between A Public And A Non-public Class?

A public class could also be accessed exterior of its package deal.

A private class is probably not accessed exterior of its package deal.

Question 170. To What Value Is A Variable Of The Boolean Type Automatically Initialized?

The default worth of the boolean kind is fake.

Question 171. Can Try Statements Be Nested?

Try statements could also be examined.

Question 172. What Is The Difference Between The Prefix And Postfix Forms Of The ++ Operator?

The prefix kind performs the increment operation and returns the worth of the increment operation.

The postfix kind returns the present worth the entire expression after which performs the increment operation on that worth.

Question 173. What Is The Purpose Of A Statement Block?

An announcement block is used to prepare a sequence of statements as a single assertion group.

Question 174. What Is A Java Package And How Is It Used?

A Java package deal is a naming context for courses and interfaces. A package deal is used to create a separate title house for teams of courses and interfaces.

Packages are additionally used to prepare associated courses and interfaces right into a single API unit and to manage accessibility to those courses and interfaces.

Question 175. What Modifiers May Be Used With A Top-level Class?

A top-level class could also be public, summary, or remaining.

Question 176. What Are The Object And Class Classes Used For?

The Object class is the highest-level class within the Java class hierarchy. The Class class is used to signify the courses and interfaces which are loaded by a Java program..

Question 177. How Does A Try Statement Determine Which Catch Clause Should Be Used To Handle An Exception?

When an exception is thrown throughout the physique of a attempt assertion, the catch clauses of the attempt assertion are examined within the order by which they seem. The first catch clause that’s able to dealing with the exception is executed. The remaining catch clauses are ignored.

Question 178. Can An Unreachable Object Become Reachable Again?

An unreachable object could change into reachable once more. This can occur when the article’s finalize() technique is invoked and the article performs an operation which causes it to change into accessible to reachable objects.

Question 179. When Is An Object Subject To Garbage Collection?

An object is topic to rubbish assortment when it turns into unreachable to this system by which it’s used.

Question 180. What Method Must Be Implemented By All Threads?

All duties should implement the run() technique, whether or not they’re a subclass of Thread or implement the Runnable interface.

Question 181. What Methods Are Used To Get And Set The Text Label Displayed By A Button Object?

getLabel() and setLabel().

Question 182. Which Component Subclass Is Used For Drawing And Painting?

Canvas.

Question 183. What Are Synchronized Methods And Synchronized Statements?

Synchronized strategies are strategies which are used to manage entry to an object. A thread solely executes a synchronized technique after it has acquired the lock for the tactic’s object or class.

Synchronized statements are much like synchronized strategies. A synchronized assertion can solely be executed after a thread has acquired the lock for the article or class referenced within the synchronized assertion.

Question 184. What Are The Two Basic Ways In Which Classes That Can Be Run As Threads May Be Defined?

A thread class could also be declared as a subclass of Thread, or it could implement the Runnable interface.

Question 185. What Are The Problems Faced By Java Programmers Who Don’t Use Layout Managers?

Without structure managers, Java programmers are confronted with figuring out how their GUI can be displayed throughout a number of windowing techniques and discovering a standard sizing and positioning that can work throughout the constraints imposed by every windowing system.

Question 186. What’s Java Swing?

Swing is basscially a sort of Toolkit which is GUI toolkit for Java. It is one a part of the Java Foundation Classes (JFC). Swing contains graphical consumer interface (GUI) widgets akin to textual content containers, buttons, split-panes, and tables.
Swing widgets present extra subtle GUI elements than the sooner Abstract Window Toolkit. Since they’re written in pure Java, they run the identical on all platforms, not like the AWT which is tied to the underlying platform’s windowing system. Swing helps pluggable feel and look � not by utilizing the native platform’s amenities, however by roughly emulating them. This means you will get any supported feel and look on any platform. The drawback of light-weight elements is slower execution. The benefit is uniform conduct on all platforms.

Question 187. What Is Jfc?

JFC stands for Java Foundation Classes. The Java Foundation Classes (JFC) are a set of Java class libraries supplied as a part of Java 2 Platform, Standard Edition (J2SE) to help constructing graphics consumer interface (GUI) and graphics performance for consumer functions that can run on widespread platforms akin to Microsoft Windows, Linux, and Mac OSX

Question 188. What Is Awt?

AWT is bassically stands for Abstract Window Toolkit. AWT allows programmers to develop Java functions with GUI elements, akin to home windows, and buttons. The Java Virtual Machine (JVM) is chargeable for translating the AWT calls into the suitable calls to the host working system.

Question 189. What Are The Differences Between Swing And Awt?

Many diff are there :
> AWT is heavy-weight elements, however Swing is lightweight elements.
> AWT is OS dependent as a result of it makes use of native elements, But Swing elements are OS unbiased.
> We can change the appear and feel in Swing which isn’t potential in AWT.
> Swing takes much less reminiscence in comparison with AWT.
> For drawing AWT makes use of display rendering the place Swing makes use of double buffering.

Question 190. What Are Heavy Weight Components ?

A Heavyweight part is bassically related to its personal native display useful resource which is generally called a peer.

Question 191. What Is Lightweight Component?

A Lightweight part is the bassically one which “borrows” the display useful resource of an ancestor , which implies it has no native useful resource of its personal — so it is “lighter”.

Question 192. What Is Double Buffering ?

Double buffering is bassically the method of use of two buffers relatively than one to quickly maintain information being moved to and from an I/O system. Double buffering will increase information switch velocity as a result of one buffer might be crammed whereas the opposite is being emptied.

Question 193. What Is An Event In Swing?

Event is basscially as Changing the state of an object is named an occasion.

Question 194. What Is An Event Handler In Swing?

An Event handler is bassically part of a pc program created to inform this system act in response to a particular occasion.

Question 195. Give Us The Name Of The List Layoutmanagers In Java?

List is right here :
> Flow Layout Manager
> Grid Layout Manager
> Box Layout Manager
> Border Layout Manager
> Card Layout Manager
> GridBag Layout Manager.

Question 196. Difference B/w Paint() And Paintcomponent()?

The Key level is that the paint() technique invokes three strategies within the following order :
> PaintComponent()
> paintBorder()
> paintChildren()
As a normal rule, in Swing, we needs to be overriding the paintComponent technique until we all know what we’re doing paintComponent() paints solely part (panel) however paint() paints part and all its kids.

Question 197. What Is The Relationship B/w The Canvas Class And The Graphics Class?

A Canvas object supplies entry to a graphics object through its paint() technique.

Question 198. When Should The Method Invokelater() Be Used?

This technique is used to make sure that Swing elements are up to date by way of the event-dispatching thread.

Question 199. What Is A Convertor?

Converter is bassically an utility that converts distance measurements between metric and U.S items.

Question 200. What Is The Difference Between Jfc & Wfc?

JFC helps strong and moveable consumer interfaces. The Swing courses are strong, suitable with AWT, and offer you a substantial amount of management over a consumer interface. Since supply code is offered, it’s comparatively straightforward to increase the JFC to do precisely what you want it to do. But the variety of third-party controls written for Swing remains to be comparatively small.
WFC runs solely on the Windows (32-bit) consumer interface, and makes use of Microsoft extensions to Java for occasion dealing with and ActiveX integration. Because ActiveX elements can be found to WFC applications, there are theoretically extra controls out there for WFC than for JFC. In follow, nonetheless, most ActiveX distributors don’t actively help WFC, so the variety of controls out there for WFC might be smaller than for JFC. The WFC programming mannequin is carefully aligned with the Windows platform.

Question 201. What Is Struts?

Struts is an online web page improvement framework and an open supply software program that helps builders construct net functions shortly and simply. Struts combines Java Servlets, Java Server Pages, customized tags, and message assets right into a unified framework. It is a cooperative, synergistic platform, appropriate for improvement groups, unbiased builders, and everybody between.

Question 202. How Is The Mvc Design Pattern Used In Struts Framework?

In the MVC design sample, utility stream is mediated by a central Controller. The Controller delegates requests to an acceptable handler. The handlers are tied to a Model, and every handler acts as an adapter between the request and the Model. The Model represents, or encapsulates, an utility’s business logic or state. Control is often then forwarded again by way of the Controller to the suitable View. The forwarding might be decided by consulting a set of mappings, often loaded from a database or configuration file. This supplies a free coupling between the View and Model, which might make an utility considerably simpler to create and keep. Controller–Servlet controller which equipped by Struts itself; View — what you’ll be able to see on the display, a JSP web page and presentation elements; Model — System state and a business logic JavaBeans.

Question 203. Who Makes The Struts?

Struts is hosted by the Apache Software Foundation(ASF) as a part of its Jakarta venture, like Tomcat, Ant and Velocity.

Question 204. Why It Called Struts?

Because the designers wish to remind us of the invisible underpinnings that maintain up our homes, buildings, bridges, and ourselves once we are on stilts. This glorious description of Struts replicate the function the Struts performs in creating internet functions.

Question 205. Do We Need To Pay The Struts If Being Used In Commercial Purpose?

No. Struts is on the market for business use at no cost beneath the Apache Software License. You may combine the Struts parts into your individual framework simply as in the event that they have been written in home with none purple tape, charges, or different hassles.

Question 206. What Are The Core Classes Of Struts?

Action, ActionForm, ActionServlet, ActionMapping, ActionForward are primary courses of Structs.

Question 207. What Is The Design Role Played By Struts?

The function performed by Structs is controller in Model/View/Controller(MVC) type. The View is performed by JSP and Model is performed by JDBC or generic information supply courses. The Struts controller is a set of programmable parts that permit builders to outline precisely how the appliance interacts with the person.

Question 208. How Struts Control Data Flow?

Struts implements the MVC/Layers sample via using ActionForwards and ActionMappings to maintain control-flow choices out of presentation layer.

Question 209. What Configuration Files Are Used In Struts?

ApplicationResources.properties
struts-config.xml
These two recordsdata are used to bridge the hole between the Controller and the Model.

Question 210. What Helpers In The Form Of Jsp Pages Are Provided In Struts Framework?

–struts-html.tld
–struts-bean.tld
–struts-logic.tld

Question 211. Is Struts Efficient?

The Struts isn’t solely thread-safe however thread-dependent(instantiates every Action as soon as and permits different requests to be threaded via the unique object.
ActionForm beans decrease subclass code and shorten subclass hierarchies.
The Struts tag libraries present general-purpose performance.
The Struts parts are reusable by the appliance.
The Struts localization methods scale back the necessity for redundant JSPs.
The Struts is designed with an open architecture–subclass obtainable.
The Struts is light-weight (5 core packages, 5 tag libraries).
The Struts is open supply and nicely documented (code to be examined simply).
The Struts is mannequin impartial.

Question 212. How You Will Enable Front-end Validation Based On The Xml In Validation.xml?

The < html:javascript > tag to permit front-end validation based mostly on the xml in validation.xml. For instance the code: < html:javascript formName=logonForm dynamicJavascript=true staticJavascript=true / > generates the shopper facet java script for the shape logonForm as outlined within the validation.xml file. The < html:javascript > when added within the jsp file generates the shopper website validation script.

Question 213. What Is Actionservlet?

The class org.apache.struts.motion.ActionServlet is the referred to as the ActionServlet. In the the Jakarta Struts Framework this class performs the function of controller. All the requests to the server goes via the controller. Controller is answerable for dealing with all of the requests.

Question 214. How You Will Make Available Any Message Resources Definitions File To The Struts Framework Environment?

Message Resources Definitions file are easy .properties recordsdata and these recordsdata comprises the messages that can be utilized within the struts venture. Message Resources Definitions recordsdata could be added to the struts-config.xml file via < message-resources / > tag. Example: < message-resources parameter= MessageResources / >

Question 215. What Is Action Class?

The Action Class is a part of the Model and is a wrapper across the business logic. The objective of Action Class is to translate the HttpServletRequest to the business logic. To use the Action, we have to Subclass and overwrite the execute() methodology. In the Action Class all of the database/business processing are completed. It is advisable to carry out all of the database associated stuffs within the Action Class. The ActionServlet (commad) passes the parameterized class to Action Form utilizing the execute() methodology. The return sort of the execute methodology is ActionForward which is utilized by the Struts Framework to ahead the request to the file as per the worth of the returned ActionForward object.

Question 216. Write Code Of Any Action Class?

Here is the code of Action Class that returns the ActionForward object.
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.motion.Action;
import org.apache.struts.motion.ActionForm;
import org.apache.struts.motion.ActionForward;
import org.apache.struts.motion.ActionMapping;
public class Take a look atAction extends Action
{
public ActionForward execute(
ActionMapping mapping,
ActionForm type,
HttpServletRequest request,
HttpServletResponse response) throws Exception

}

Question 217. What Is Actionform?

An ActionForm is a JavaBean that extends org.apache.struts.motion.ActionForm. ActionForm maintains the session state for internet utility and the ActionForm object is robotically populated on the server facet with information entered from a type on the shopper facet.

Question 218. What Is Struts Validator Framework?

Struts Framework offers the performance to validate the shape information. It could be use to validate the information on the customers browser in addition to on the server facet. Struts Framework emits the java scripts and it may be used validate the shape information on the shopper browser. Server facet validation of type could be completed by sub classing your From Bean with DynaValidatorForm class. The Validator framework was developed by David Winterfeldt as third-party add-on to Struts. Now the Validator framework is part of Jakarta Commons venture and it may be used with or with out Struts. The Validator framework comes built-in with the Struts Framework and can be utilized with out doing any additional settings.

Question 219. Give The Details Of Xml Files Used In Validator Framework?

The Validator Framework makes use of two XML configuration recordsdata validator-rules.xml and validation.xml. The validator-rules.xml defines the usual validation routines, these are reusable and utilized in validation.xml. to outline the shape particular validations. The validation.xml defines the validations utilized to a type bean. How you’ll show validation fail errors on jsp web page? – The following tag shows all of the errors: < html:errors/ >

Question 220. Why Do We Need Struts?

Java applied sciences give builders a severe enhance when creating and sustaining functions to satisfy the calls for of right now’s public Web websites and enterprise intranets. Struts combines Java Servlets, Java ServerPages, customized tags, and message sources right into a unified framework. The finish result’s a cooperative, synergistic platform, appropriate for growth groups, impartial builders, and everybody in between.

Question 221. How Does Struts Work?

Java Servlets are designed to deal with requests made by Web browsers. Java ServerPages are designed to create dynamic Web pages that may flip billboard websites into stay functions. Struts makes use of a particular Servlet as a switchboard to route requests from Web browsers to the suitable ServerWeb page. This makes Web functions a lot simpler to design, create, and preserve.

Question 222. Is Struts Compatible With Other Java Technologies?

Yes. Struts is dedicated to supporting trade requirements. Struts acts as an integrator of Java applied sciences in order that they can be utilized within the “actual world”.

Question 223. Who Wrote Struts?

There are a number of lively committers to the Struts venture, working cooperatively from across the globe. Dozens of particular person builders and committers contributed to the Struts 1.x codebase. All Java builders are invited to contribute to the venture. Struts is a Apache Software Foundation venture, with the mission to “present safe, enterprise-grade server options based mostly on the Java Platform which are developed in an open and cooperative vogue”.

Struts was created by Craig R. McClanahan and donated to The Apache Software Foundation in May 2000. Craig was the first developer of each Struts 1.x and Tomcat 4. Tomcat Four was the premise for the official reference implementation for a servlet 2.three and JSP 1.2 container.

Craig’s present focus is as architect of the Sun Java Studio Creator (previously Project Rave). Craig additionally serves because the Specification Lead for JavaServer Faces (JSR-127), and is the Web Layer Architect for the Java2 Enterprise Edition (J2EE) platform as an entire.

Question 224. Why Is It Called Struts?

It’s a reference to struts within the architectural sense, a reminder of the practically invisible items that maintain up buildings, homes, and bridges.

Question 225. Do I Have To Credit Struts On My Own Website?

You must credit score Struts when you redistribute your individual framework based mostly on Struts for different folks to make use of. (See the Apache License for particulars.) But you do not want to credit score Struts simply because your internet utility makes use of the framework. It’s the identical state of affairs as utilizing the Apache HTTPD server or Tomcat. Not required if its simply operating your web page.

Question 226. Where Can I Get A Copy Of Struts?

The finest place to obtain Struts is at struts.apache.org. The nightly builds are very secure, and really helpful as the most effective place to start out right now.

Question 227. How Do I Install Struts?

To develop functions with Struts, you possibly can often simply add the Struts JAR file to your Java growth atmosphere. You can then begin utilizing the Struts courses as a part of your individual utility. A clean Struts utility (within the webapps listing, open struts-blank.warfare) is supplied, which you’ll be able to simply copy to get a quick-start by yourself brainchild.

Since the complete supply code for Struts is on the market, we additionally present full directions for compiling your individual Struts JAR from scratch. (This is definitely simpler than it appears!)

Your Struts utility can often be deployed utilizing a regular WAR file. In most instances, you merely deposit the WAR file in your utility server, and it’s put in robotically. If not, step-by-step set up directions for varied servlet containers can be found.

Question 228. When Do I Need “struts.jar” On My Classpath?

When you might be compiling an utility that makes use of the Struts courses, you will need to have the “struts.jar” on the classpath your compiler sees — it doesn’t need to be in your CLASSPATH atmosphere variable.

Why is that an necessary distinction? Because if you’re utilizing a servlet container in your growth machine to check your utility, the “struts.jar” should not be in your CLASSPATH atmosphere variable when operating the container. (This is as a result of every Web utility should even have their very own copy of the Struts courses, and the container will grow to be confused whether it is on the atmosphere path as nicely.)

There are a number of basic approaches to this challenge:

* Use ANT for constructing your tasks — it could simply assemble classpaths for the compiler. (This is how Struts itself is constructed, together with Tomcat and most different Java-based tasks).
* Use an IDE the place you possibly can configure the “class path” used for compilation impartial of the CLASSPATH atmosphere variable.
* Use a shell script that quickly provides struts.jar to the classpath only for compilation, for instance javac -classpath /path/to/struts.jar:$CLASSPATH $@

Question 229. Does Struts Include Its Own Unit Tests?

Struts presently has two testing environments, to replicate the truth that some issues could be examined statically, and a few actually have to be completed within the atmosphere of a operating servlet container.

For static unit exams, we use the JUnit framework. The sources for these exams are within the “src/check” hierarchy within the supply repository, and are executed through the “check.junit” goal within the top-level construct.xml file. Such exams are targeted on the low-level performance of particular person strategies, are significantly appropriate for the static strategies within the org.apache.struts.util utility courses. In the check hierarchy, there are additionally some “mock object” courses (within the org.apache.struts.mock bundle) so as to bundle up issues that appear like servlet API and Struts API objects to go in as arguments to such exams.

Another priceless device is Struts TestCase which offers a helpful harness for Action courses that can be utilized with JUnit or Cactus.

Question 230. If The Framework Doesn’t Do What I Want, Can I Request That A Feature Be Added?

First, it is necessary to keep in mind that Struts is an all-volunteer venture. We do not cost anybody something to make use of Struts. Committers and different builders work on Struts as a result of they should use it with their very own functions. If others can use it too, that is “icing on the cake”. If you submit a patch for a function {that a} Committer finds helpful, then that Committer could select to volunteer his or her time to use the patch. If you simply submit an thought and not using a patch, it’s a lot much less prone to be added (since first another person has to volunteer their time to jot down the patch).

We are grateful for any patches, and we welcome new concepts, however one of the best ways to see that one thing will get added to the framework is to do as a lot of the work as you possibly can, relatively than depend on the “kindness of strangers”. Worst case, you possibly can apply the patch to your copy of Struts and nonetheless use the function in your individual utility. (Which is what open supply is absolutely all about.)

Question 231. Where Can I Get Help With Struts?

The Struts bundle comes full with a Users Guide to introduce folks to the framework and its underlying applied sciences. Various parts even have their very own in-depth Developers Guide, to cowl extra superior matters. Comprehensive Javadocs are included together with the complete supply code. For your comfort, these are bundled collectively as a self-installing utility. The struts-documentation.warfare is identical bundle that’s deployed because the Struts Web website.

The Strut’s mailing record can be very lively, and welcomes posts from new customers. Before posting a brand new query, make sure to seek the advice of the MAILING LIST ARCHIVE and the very glorious How To Ask Questions The Smart Way by Eric Raymond. Please do make sure to flip off HTML in your e mail shopper earlier than posting.

Question 232. What’s The Difference Between Struts And Turbine? What’s The Difference Between Struts And Espresso?

If you might be ranging from scratch, packages like Turbine and Espresso could be very useful since they attempt to present all the primary providers that your group is prone to want. Such providers embody issues like information persistence and logging.

If you aren’t ranging from scratch, and must hook up your internet utility to an present infrastructure, then “plain vanilla” Struts could be a more sensible choice. The core Struts framework doesn’t presuppose that you’re utilizing a given set of information persistence, presentation, or logging instruments. Anything goes =:0)

Compared to different choices, Struts endeavors to be a minimalist framework. We attempt leverage present applied sciences every time we are able to and supply solely the lacking items you must mix disparate applied sciences right into a coherent utility. This is nice while you wish to choose your individual instruments to make use of with Struts. But, when you want a extra built-in infrastructure, then packages like Turbine or Espresso (which makes use of Struts) are completely good methods to go.

See additionally

* < http://www.mail-archive.com/struts-user@jakarta.apache.org/msg03206.html >
* < http://www.mail-archive.com/general@jakarta.apache.org/msg00495.html >
* < http://jakarta.apache.org/velocity/ymtd/ymtd.html >

Question 233. Why Aren’t The Struts Tags Maintained As Part Of The Jakarta Taglibs Project ?

Development of each merchandise started about the identical time. Leading as much as the discharge of 1.0, it was thought higher to proceed to develop the taglibs alongside the controller. Now that 1.Zero is out, the JavaServer Pages Standard Taglib is in lively growth. Once work on JSTL stabilizes, the Struts taglibs will likely be revisited. Tags which aren’t linked on to the framework could also be hosted at Jakarta Taglibs as a substitute.

Question 234. Are The Struts Tags Xhtml Compliant ?

If you employ an <html:html xhtml=”true> or <html:xhtml/> aspect in your web page, the tags will render as XHTML (since Struts 1.1).

Question 235. Will The Struts Tags Support Other Markup Languages Such As Wml ?

Struts itself is markup impartial. The authentic Struts taglibs are just one instance of how presentation layer parts can entry the framework. The framework objects are uncovered via the usual utility, session, and request contexts, the place any Java element within the utility could make use of them.

Markup extensions that use Struts can be found for Velocity and XLST, amongst others. A brand new Struts tag library for Java Server Faces can be in growth.

For extra about utilizing WAP/WML with Struts see the article WAP up your EAserver.

Question 236. What About Jstl And Javaserver Faces ?

JSTL, the JavaServer Standard Tag Library, is a set of JSP tags which are designed to make it simpler to develop Web functions. JavaServer Faces (JSF) is a specification for a brand new expertise that guarantees to make it simpler to jot down MVC functions, each for the Web and for the desktop.

The inventor of Struts, Craig McClanahan, is the specification co-lead for JavaServer Faces (JSR 127), and architect of the reference implemenation in addition to Java Studio Creator. Both JSTL and JSF are complementary to Struts.

The mainstay of the Struts framework is the controller parts, which can be utilized with any Java presentation expertise. As new applied sciences grow to be obtainable, it’s sure that new “glue” parts will even seem to assist these applied sciences work as nicely with Struts.

Struts initially got here bundled with a set of customized JSP tags. Today, a number of extensions can be found that can assist you use Struts with different well-liked presentation applied sciences, like XSLT and Velocity. Likewise, extensions for JSTL and JSF are actually obtainable as nicely.

The JSTL reference implementation is on the market via the Jakarta Taglibs website. A JSTL taglibs for Struts, Struts-El , is on the market and distributed with Struts starting with the 1.1 launch.

The JSF specification and reference implementation is on the market via Sun’s The JSF specification and reference implementation is on the market via Sun’s Java ServerFaces web page. An early-release JavaServer Faces taglib for Struts, Struts-Faces, can be in early launch and obtainable via the nightly construct. The Struts Faces taglib is predicted to work with any compliant JSF implementation, together with MyFaces.

Question 237. Is There A Particularly Good Ide To Use With Struts?

Struts ought to work nicely with any growth atmosphere that you simply wish to use, in addition to with any programmers editor. The members of the Struts growth group every use their very own instruments akin to Emacs, IDEA, Eclipse, and InternetBeans.

Question 238. Why Was Reload Removed From Struts (since 1.1)?

The downside with ReloadAction was that Struts was making an attempt to behave like a container, but it surely could not do a correct job of it. For instance, you possibly can’t reload courses which have been modified, or (portably) add new courses to a operating internet utility (even when the container supported it).

Meanwhile, as Struts 1.1 was being developed, work progressed on issues like Tomcat’s reload command through the Manager webapp. This function means that you can shortly reload-on-demand, full with saving and restoring your session). It began to make even much less sense for Struts to half-implement a function that containers are implementing totally.

A extra minor level is that freezing the configuration info at utility startup time permits Struts to soundly entry the mapping info with out bothering with synchronization. The “startup-only” technique creates a modest however actual enchancment in efficiency for all customers.

So, ReloadAction isn’t supported since Struts 1.1 for 2 causes:

* It by no means did allow you to reload every thing that you’d actually wish to — significantly modified courses — so many individuals ended up having to reload the webapp anyway.
* Containers are beginning to supply reload-on-demand options which does the identical factor because the Struts ReloadAction, solely higher.
* Not supporting ReloadAction lets Struts keep away from doing synchronization locks round all of the lookups (like determining which motion to make use of, or the vacation spot of an ActionForward) so functions can run a bit quicker.

Of course, if somebody got here up with an implementation that solved these issues with out creating any others, we might not be against together with a brand new ReloadAction.

Question 239. What Is A Modular Application? What Does Module-relative Mean?

Since Struts 1.1, the framework helps a number of utility modules. All functions have not less than one root, or default, module. Like the foundation listing in a file system, the default utility has no title. (Or is known as with an empty string, relying your viewpoint.) Developing an utility with solely a default module is not any totally different from how functions have been developed beneath Struts 1.0. Since Struts 1.1, you possibly can add further modules to your utility, every of which may have their very own configuration recordsdata, messages sources, and so forth. Each module is developed in the identical approach because the default module. Applications that have been developed as a single module can added to a a number of module utility, and modules can promoted to a standalone utility with out change. For extra about configuring your utility to assist a number of modules, see Configuring Applications within the User Guide.

But to reply the query =:0), a modular utility is a Struts utility that makes use of multiple module. Module-relative signifies that the URI begins on the module stage, relatively than on the context stage, or the absolute-URL stage.

* Absolute URL: http://localhost/myApplication/myModule/myAction.do
* context-relative: /myModule/myAction.do
* module-relative: /myAction.do
The Struts Examples utility is a modular utility that was assembled from a number of functions that have been created independently.

Question 240. Why Are Some Of The Class And Element Names Counter-intuitive?

The framework grew within the telling and, because it developed, among the names drifted. The advantage of a nightly construct, is that every thing turns into obtainable to the group as quickly as it’s written. The dangerous factor a couple of nightly construct is that issues like class names get locked down early after which grow to be troublesome to alter.

Question 241. Why Is Actionform A Base Class Rather Than An Interface?

The MVC design sample may be very easy to know however way more troublesome to stay with. You simply want this little little bit of Business Logic within the View logic otherwise you want simply that little little bit of View logic within the Business tier and fairly quickly you will have an actual mess.

Making ActionForm a category takes benefit of the one inheritance restriction of Java to it makes it tougher for folks to do issues that they need to not do.

ActionForms applied as interfaces encourage making the property sorts match the underlying business tier as a substitute of Strings, which violates one of many main functions for ActionForms within the first place (the flexibility to breed invalid enter, which is a basic person expectation). ActionForms as an interface would additionally encourage utilizing present DAO objects as ActionForms by including implements ActionForm to the category. This violates the MVC design sample aim of separation of the view and business logic.

Since the aim of struts is to implement this separation, it simply makes extra sense for Struts to personal the ActionForm.

DynaActionForms relieve builders of sustaining easy ActionForms. For close to zero upkeep, attempt Niall Pemberton’s LazyActionForm.

Question 242. Do Actionforms Have To Be True Javabeans?

The utilities that Struts makes use of (Commons-BeanUtils since 1.1) require that ActionForm properties comply with the JavaBean patterns for mutators and accessors (get*,set*,is*). Since Struts makes use of the Introspection API with the ActionForms, some containers might require that each one the JavaBean patterns be adopted, together with declaring “implements Serializable” for every subclass. The most secure factor is to assessment the JavaBean specification and comply with all of the prescribed patterns.

Since Struts 1.1, you can too use DynaActionForms and mapped-backed kinds, which aren’t true JavaBeans. For extra see ActionForm lessons within the User Guide and Using Hashmaps with ActionForms on this FAQ.

Question 243. Can I Use Multiple Html Form Elements With The Same Name?

Yes. Define the ingredient as an array and Struts will autopopulate it like another.
personal String[] id= {};
public String[] getId() { return this.id; }
public void setItem(String id[]) {this.id = id;}
And so forth

Question 244. Why Doesn’t The Focus Feature On The Tag Work In Every Circumstance?

Unfortunately, there may be some disagreement between the assorted browsers, and completely different variations of the identical browser, as to how the main focus may be set. The <html:type> tag offers a fast and straightforward JavaScript that may set the concentrate on a type for many variations of most browsers. If this function would not be just right for you, then it is best to set the main focus utilizing your individual JavaScript. The focus function is a handy “value-add” — not a core requirement of the tag. If you do give you a JavaScript that gives the ultimate answer to this mission, please post your patch to this Bugzilla ticket.

Question 245. Why Are My Checkboxes Not Being Set From On To Off?

An issue with a checkbox is that the browser will solely embrace it within the request when it’s checked. If it’s not checked, the HTML specification means that it not be despatched (i.e. omitted from the request). If the worth of the checkbox is being continued, both in a session bean or within the mannequin, a checked field can by no means unchecked by a HTML type — as a result of the shape can by no means ship a sign to uncheck the field. The utility should someway confirm that because the ingredient was not despatched that the corresponding worth is unchecked.

The really helpful strategy for Struts functions is to make use of the reset methodology within the ActionForm to set all properties represented by checkboxes to null or false. The checked packing containers submitted by the shape will then set these properties to true. The omitted properties will stay false. Another answer is to make use of radio buttons as an alternative, which at all times submit a worth.

It is essential to notice that the HTML specification recommends this similar conduct each time a management will not be “profitable”. Any clean ingredient in a HTML type will not be assured to submitted. It is therefor essential to set the default values for an ActionForm appropriately, and to implement the reset methodology when the ActionForm may stored in session scope.

Question 246. Can’t I Just Create Some Of My Javabeans In The Jsp Using A Scriptlet?

Struts is designed to encourage a Model 2/MVC structure. But there may be nothing that forestalls you from utilizing Model 1 strategies in your JavaServer Pages, so the reply to the query is “Yes, you possibly can”.

Though, utilizing Model 1 strategies in a Struts utility does go in opposition to the grain. The strategy really helpful by most Struts builders is to create and populate no matter objects the view might have within the Action, after which ahead these by the request. Some objects can also be created and saved within the session or context, relying on how they’re used.

Likewise, there may be nothing to stop you from utilizing scriptlets together with JSP tags in your pages. Though, many Struts builders report writing very complicated scriplet-free functions and advocate the JSP tag strategy to others.

For assist with Model 1 strategies and scriptlets, you may think about becoming a member of the Javasoft JSP-interest mailing record, the place there are extra folks nonetheless utilizing these approaches.

Question 247. Can I Use Javascript To Submit A Form?

You can submit a type with a link as under. BTW, the examples under assume you might be in an block and ‘myForm’ is picked up from the struts-config.xml title discipline of the motion.

<a href=’javascript:void(doc.kinds[“myForm”].submit()>My Link</a>
Now the trick within the motion is to decode what motion you propose to carry out. Since you might be utilizing JavaScript, you possibly can set a discipline worth and search for it within the request or within the type.
… html/javascript half …
<enter sort=’hidden’ worth=’myAction’ />
<enter sort=’button’ worth=’Save Meeeee’
onclick=’doc.kinds[“myForm”].myAction.worth=”save”;
doc.kinds[“myForm”].submit();’ />
<enter sort=’button’ worth=’Delete Meeeee’
onclick=’doc.kinds[“myForm”].myAction.worth=”delete”;
doc.kinds[“myForm”].submit();’ />
… the java half …
class MyAction extends ActionForm implements Serializable {

public ActionForward execute (ActionMapping map, ActionForm type,
HttpServletRequest req, HttpServletResponse) {

String myAction = req.getParameter(“myAction”);

if (myAction.equals(“save”) else if (myAction.equals(“delete”)
// … delete motion …

}
}
}

This is only one of some ways to realize submitting a type and decoding the supposed motion. Once you get used to the framework you’ll find different ways in which make extra sense on your coding model and necessities. Just bear in mind this instance is totally non-functional with out JavaScript.

Question 248. How Can I Scroll Through List Of Pages Like The Search Results In Google?

Many Struts builders use the Pager from the JSPTags website.
http://jsptags.com/tags/navigation/pager/

Question 249. Why Do The Struts Tags Provide For So Little Formatting?

The Struts tags appear to offer solely essentially the most rudimentary performance. Why is there not higher assist for date formatting and superior string dealing with?

Three causes:

First, work began on the JSTL and we did not need to duplicate the hassle.
Second, work began on Java Server Faces, and we did not need to duplicate that effort both.

Third, in a Model 2 utility, many of the formatting may be dealt with within the ActionForms (or within the business tier), so all of the tag has to do is spit out a string. This results in higher reuse because the similar “methods to format” code doesn’t should be repeated in each occasion. You can “say it as soon as” in a JavaBean and be accomplished with it. Why do not the Struts taglibs provide extra format choices?

Since the Struts tags are open supply, you possibly can lengthen them to offer no matter further formatting it’s possible you’ll want. If you have an interest in a pre-written taglib that gives extra format choices, see the struts-layout taglib.

In the identical enviornment, there’s a effectively regarded contributor taglib that may enable you create Menus on your Struts functions.

Question 250. Why Does The Tag Url-encode Javascript And Mailto Links?

The <html:link> tag will not be supposed to be used with client-side references like these used to launch Javascripts or electronic mail purchasers. The goal of link tag is to interject the context (or module) path into the URI in order that your server-side hyperlinks are usually not dependent in your context (or module) title. It additionally encodes the link, as wanted, to take care of the shopper’s session on the server. Neither function applies to client-side hyperlinks, so there is no such thing as a purpose to make use of the <html:link> tag. Simply markup the client-side hyperlinks utilizing the usual tag.

Question 251. Why Does The Option Tag Render Selected=chosen Instead Of Just Selected?

Attribute minimization (that’s, specifying an attribute with no worth) is a spot the place HTML violates normal XML syntax guidelines. This issues loads for folks writing to browsers that assist XHTML, the place doing so makes the web page invalid. It’s a lot better for Struts to make use of the expanded syntax, which works the identical on present browsers deciphering HTML, and newer browsers that anticipate XHTML-compliant syntax. Struts is following the conduct really helpful by the XHTML specification.

Question 252. Do I Have To Use Jsps With My Application?

The brief reply to this query is: No, you aren’t restricted to JavaServer Pages.
The longer reply is that you should use any sort of presentation know-how which may be returned by an internet server or Java container. The record contains however will not be restricted to:
* JavaServer Pages,
* HTML pages,
* WML information,
* Java servlets,
* Velocity templates, and
* XML/XLST
Some folks even combine and match apparently unrelated applied sciences, like PHP, into the identical net utility.

Question 253. Can I Have An Action Without A Form?

Yes. If your Action doesn’t want any knowledge and it doesn’t have to make any knowledge accessible to the view or controller element that it forwards to, it would not want a type. A very good instance of an Action with no ActionForm is the LogoffAction within the struts instance utility:

<motion path=”/logoff”
sort=”org.apache.struts.webapp.instance.LogoffAction”>
<ahead title=”success” path=”/index.jsp”/>
</motion>

This motion wants no knowledge apart from the person’s session, which it will possibly get from the Request, and it would not want to organize any view components for show, so it doesn’t want a type.

However, you can’t use the <html:type> tag with out an ActionForm. Even if you wish to use the <html:type> tag with a easy Action that doesn’t require enter, the tag will anticipate you to make use of some sort of ActionForm, even whether it is an empty subclass with none properties.

Question 254. Can You Give Me A Simple Example Of Using The Requiredif Validator Rule?

First off, there’s an excellent newer Validator rule known as validwhen, which is nearly actually what you need to use, since it’s a lot simpler and extra highly effective. It can be accessible within the first launch after 1.1 ships.
The instance proven under may very well be coded with validwhen as:

<type title=”medicalStatusForm”>

<discipline
property=”pregnancyTest” relies upon=”validwhen”>
<arg0 key=”medicalStatusForm.pregnancyTest.label”/>
<var>
<var-name>take a look at</var-name>
<var-value>((((intercourse == ‘m’) OR (intercourse == ‘M’))
AND (*this* == null)) OR (*this* != null))</take a look at>
</var>
</discipline>

Let’s assume you’ve a medical info type
with three fields,
intercourse, pregnancyTest, and testResult. If intercourse is ‘f’ or ‘F’,
pregnancyTest is required. If pregnancyTest will not be clean,
testResult is required. The entry in your validation.xml
file would appear to be this:

<type title=”medicalStatusForm”>

<discipline
property=”pregnancyTest” relies upon=”requiredif”>
<arg0 key=”medicalStatusForm.pregnancyTest.label”/>
<var>
<var-name>discipline[0]</var-name>
<var-value>intercourse</var-value>
</var>
<var>
<var-name>fieldTest[0]</var-name>
<var-value>EQUAL</var-value>
</var>
<var>
<var-name>fieldValue[0]</var-name>
<var-value>F</var-value>
</var>
<var>
<var-name>discipline[1]</var-name>
<var-value>intercourse</var-value>
</var>
<var>
<var-name>fieldTest[1]</var-name>
<var-value>EQUAL</var-value>
</var>
<var>
<var-name>fieldValue[1]</var-name>
<var-value>f</var-value>
</var>
<var>
<var-name>fieldJoin</var-name>
<var-value>OR</var-value>
</var>
</discipline>

<discipline
property=”testResult” relies upon=”requiredif”>
<arg0 key=”medicalStatusForm.testResult.label”/>
<var>
<var-name>discipline[0]</var-name>
<var-value>pregnancyTest</var-value>
</var>
<var>
<var-name>fieldTest[0]</var-name>
<var-value>NOTNULL</var-value>
</var>
</discipline>
</type>

Question 255. When Is The Best Time To Validate Input?

This is a superb query. Let’s step again a second and take into consideration a typical mid to massive measurement utility. If we begin from the again finish and work towards the view we now have:
1) Database: Most trendy databases are going to validate for required fields, duplicate data, safety constraints, and so on.
2) Business Logic: Here you will test for legitimate knowledge relationships and issues that make sense for the actual downside you might be triing to unravel.
… This is the place struts comes into the image, by now the system ought to be fairly effectively bulletproof. What we’re going to do is make validation friendlier and informative. Rember it’s OK to have duplicate validations…
3) ActionErrors validate(ActionMapping map, HttpServletRequest req) is the place you are able to do your validation and feed again to the view, info required to appropriate any errors. validate is run after the shape has been reset and after the ActionForm properties have been set from corresponding view based mostly enter. Also bear in mind you possibly can flip validation off with validate=”false” within the motion mapping within the struts-config.xml. This is finished by returning an ActionErrors assortment with messages out of your ApplicationAssets.properties file.
Here you’ve entry to the request so you possibly can see what sorts of motion is being requested to tremendous tune your validations. The <html:error> tag means that you can dump all errors in your web page or a specific error related to a specific property. The enter attribute of the struts-config.xml motion means that you can ship validation errors to a specific jsp / html / tile web page.
4) You can have the system carry out low stage validations and shopper facet suggestions utilizing a ValidatorForm or its derivatives. This will generate javascript and provides immediate suggestions to the person for easy knowledge entry errors. You code your validations within the validator-rules.xml file. A working information of normal expressions is important to make use of this function successfully.

Question 256. How Can I Avoid Validating A Form Before Data Is Entered?

The easiest way is to have two actions. The first one has the job of setting the shape knowledge, i.e. a clean registration display. The second motion in our writes the registration knowledge to the database. Struts would deal with invoking the validation and returning the person to the right display if validation was not full.

The EditRegistration motion within the struts instance utility illustrates this:

< motion path=”/editRegistration”>
sort=”org.apache.struts.webapp.instance.EditRegistrationAction”
attribute=”registrationForm”
scope=”request”
validate=”false”>
<ahead title=”success path=”/registration.jsp”/>
</motion>

When the /editRegistration motion is invoked, a registrationForm is created and added to the request, however its validate methodology will not be known as. The default worth of the validate attribute is true, so if you don’t want an motion to set off type validation, you must bear in mind so as to add this attribute and set it to false.

Question 257. Declarative Exception Handling

If you’ve developed net functions lengthy sufficient, you’ll notice a recurring sample emerges: when the backend (e.g. the EJB tier) throws you an exception, you almost at all times have to show an error web page comparable to the kind of that exception. Sooner or later, you’ll give you a mechanism to make use of a lookup desk (e.g. an HashMap) to lookup an error web page from the exception class.

Struts 1.1 now offers the same however extra highly effective mechanism to declare exception dealing with. In Struts 1.1, you possibly can declare within the struts-config.xml the associations between an exception class and an exception handler. Using the default exception handler included in Struts, you can too specify the trail of the error pages. With this info, Struts will robotically ahead to the required pages when an uncaught exception is thrown from an Action.

Like different services in Struts, the exception handlers are pluggable. You can write and outline your individual handler lessons if wanted.

Question 258. What Is Hibernate?

Hibernate is a strong, excessive efficiency object/relational persistence and question service.

This lets the customers to develop persistent lessons following object-oriented rules reminiscent of affiliation, inheritance, polymorphism, composition, and collections.

Question 259. What Is Orm?

ORM stands for Object/Relational mapping. It is the programmed and translucent perseverance of objects in a Java utility in to the tables of a relational database utilizing the metadata that describes the mapping between the objects and the database. It works by reworking the information from one illustration to a different.

Question 260. What Does An Orm Solution Comprises Of?

• It ought to have an API for performing primary CRUD (Create, Read, Update, Delete) operations on objects of persistent lessons.
• Should have a language or an API for specifying queries that confer with the lessons and the properties of lessons.
• An skill for specifying mapping metadata.
• It ought to have a way for ORM implementation to work together with transactional objects to carry out soiled checking, lazy affiliation fetching, and different optimization features.

Question 261. What Are The Different Levels Of Orm Quality?

There are 4 ranges outlined for ORM high quality.
i. Pure relational
ii. Light object mapping
iii. Medium object mapping
iv. Full object mapping.

Question 262. What Is A Pure Relational Orm?

The complete utility, together with the person interface, is designed across the relational mannequin and SQL-based relational operations.

Question 263. What Is A Meant By Light Object Mapping?

The entities are represented as lessons which are mapped manually to the relational tables. The code is hidden from the business logic utilizing particular design patterns. This strategy is profitable for functions with a much less variety of entities, or functions with widespread, metadata-driven knowledge fashions. This strategy is most identified to all.

Question 264. What Is A Meant By Medium Object Mapping?

The utility is designed round an object mannequin. The SQL code is generated at construct time. And the associations between objects are supported by the persistence mechanism, and queries are specified utilizing an object-oriented expression language. This is greatest fitted to medium-sized functions with some complicated transactions. Used when the mapping exceeds 25 completely different database merchandise at a time.

Question 265. What Is Meant By Full Object Mapping?

Full object mapping helps refined object modeling: composition, inheritance, polymorphism and persistence. The persistence layer implements clear persistence; persistent lessons don’t inherit any particular base class or need to implement a particular interface. Efficient fetching methods and caching methods are applied transparently to the appliance.

Question 266. What Are The Benefits Of Orm And Hibernate?

There are many advantages from these. Out of which the next are a very powerful one.
i. Productivity – Hibernate reduces the burden of developer by offering a lot of the performance and let the developer to focus on business logic.
ii. Maintainability – As hibernate offers many of the performance, the LOC for the appliance can be decreased and it’s simple to take care of. By automated object/relational persistence it even reduces the LOC.
iii. Performance – Hand-coded persistence offered larger efficiency than automated one. But this isn’t true all of the instances. But in hibernate, it offers extra optimization that works on a regular basis there by rising the efficiency. If it’s automated persistence then it nonetheless will increase the efficiency.
iv. Vendor independence – Irrespective of the several types of databases which are there, hibernate offers a a lot simpler technique to develop a cross platform utility.

Question 267. How Does Hibernate Code Looks Like?

Session session = getSessionManufacturing facility().openSession();
Transaction tx = session.startTransaction();
MyPersistanceClass mpc = new MyPersistanceClass (“Sample App”);
session.save(mpc);
tx.commit();
session.shut();
The Session and Transaction are the interfaces offered by hibernate. There are many different interfaces apart from this.

Question 268. What Is A Hibernate Xml Mapping Document And How Does It Look Like?

In order to make many of the issues work in hibernate, often the data is offered in an xml doc. This doc is named as xml mapping doc. The doc defines, amongst different issues, how properties of the person outlined persistence lessons’ map to the columns of the relative tables in database.

<?xml model=”1.0″?> <!DOCTYPE hibernate-mapping PUBLIC
“http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd”>
<hibernate-mapping>
<class title=”pattern.MyPersistanceClass” desk=”MyPersitaceTable”>
<id title=”id” column=”MyPerId”> <generator class=”increment”/>
</id>
<property title=”textual content” column=”Persistance_message”/>
<many-to-one title=”nxtPer” cascade=”all” column=”NxtPerId”/>
</class>
</hibernate-mapping>
Everything ought to be included below <hibernate-mapping> tag. This is the principle tag for an xml mapping doc.

Question 269. What The Core Interfaces Are Of Hibernate Framework?

There are many advantages from these. Out of which the next are a very powerful one.

i. Session Interface – This is the first interface utilized by hibernate functions. The cases of this interface are light-weight and are cheap to create and destroy. Hibernate periods are usually not thread secure.
ii. SessionManufacturing facility Interface – This is a manufacturing facility that delivers the session objects to hibernate utility. Generally there can be a single SessionManufacturing facility for the entire utility and it will likely be shared amongst all the appliance threads.
iii. Configuration Interface – This interface is used to configure and bootstrap hibernate. The occasion of this interface is utilized by the appliance with a purpose to specify the placement of hibernate particular mapping paperwork.
iv. Transaction Interface – This is an optionally available interface however the above three interfaces are obligatory in every utility. This interface abstracts the code from any sort of transaction implementations reminiscent of JDBC transaction, JTA transaction.
v. Query and Criteria Interface – This interface permits the person to carry out queries and likewise management the circulate of the question execution.

Question 270. What Are Callback Interfaces?

These interfaces are used within the utility to obtain a notification when some object occasions happen. Like when an object is loaded, saved or deleted. There isn’t any have to implement callbacks in hibernate functions, however they’re helpful for implementing sure sorts of generic performance.

Question 271. What Are Extension Interfaces?

When the built-in functionalities offered by hibernate will not be adequate sufficient, itprovides a approach in order that person can embrace different interfaces and implement these interfaces for person need performance. These interfaces are known as as Extension interfaces.

Question 272. What Are The Extension Interfaces That Are There In Hibernate?

There are many extension interfaces offered by hibernate.
ProxyFactory interface – used to create proxies
ConnectionProvider interface – used for JDBC connection administration
TransactionManufacturing facility interface – Used for transaction administration
Transaction interface – Used for transaction administration
TransactionAdministrationLookup interface – Used in transaction administration.
Cahce interface – offers caching strategies and methods
CacheProvider interface – similar as Cache interface
ClassPersister interface – offers ORM methods
IdentifierGenerator interface – used for major key technology
Dialect summary class – offers SQL assist.

Question 273. What Are Different Environments To Configure Hibernate?

There are primarily two sorts of environments through which the configuration of hibernate utility differs.
i. Managed surroundings – In this sort of surroundings the whole lot from database connections, transaction boundaries, safety ranges and all are outlined. An instance of this sort of surroundings is surroundings offered by utility servers reminiscent of JBoss, Weblogic and WebSphere.
ii. Non-managed surroundings – This sort of surroundings offers a primary configuration template. Tomcat is among the greatest examples that present this sort of surroundings.

Question 274. What Is The File Extension You Use For Hibernate Mapping File?

The title of the file ought to be like this : filename.hbm.xml
The filename varies right here. The extension of those information ought to be “.hbm.xml”.
This is only a conference and it’s not obligatory. But that is the very best apply to comply with this extension.

Question 275. What Do You Create A Sessionfactory?

Configuration cfg = new Configuration();
cfg.addResource(“myinstance/MyConfig.hbm.xml”);
cfg.setProperties( System.getProperties() );
SessionManufacturing facility classes = cfg.constructSessionManufacturing facility();
First, we have to create an occasion of Configuration and use that occasion to confer with the situation of the configuration file. After configuring this occasion is used to create the SessionManufacturing facility by calling the tactic constructSessionManufacturing facility().

Question 276. What Is Meant By Method Chaining?

Method chaining is a programming approach that’s supported by many hibernate interfaces. This is much less readable when in comparison with precise java code. And it’s not necessary to make use of this format. Look how a SessionManufacturing facility is created once we use methodology chaining.

SessionManufacturing facility classes = new Configuration()
.addResource(“myinstance/MyConfig.hbm.xml”)
.setProperties( System.getProperties() )
.constructSessionManufacturing facility();

Question 277. What Does Hibernate.properties File Consist Of?

This is a property file that must be positioned in software class path. So when the Configuration object is created, hibernate is first initialized. At this second the applying will mechanically detect and browse this hibernate.properties file.
hibernate.connection.datasource = java:/comp/env/jdbc/AuctionDB
hibernate.transaction.factory_class =
web.sf.hibernate.transaction.JTATransactionManufacturing facility
hibernate.transaction.manager_lookup_class =
web.sf.hibernate.transaction.JBossTransactionSupervisorLookup
hibernate.dialect = web.sf.hibernate.dialect.PostgreSQLDialect

Question 278. What Should Sessionfactory Be Placed So That It Can Be Easily Accessed?

As far as it’s in comparison with J2EE surroundings, if the SessionManufacturing facility is positioned in JNDI then it may be simply accessed and shared between totally different threads and numerous parts which might be hibernate conscious. You can set the SessionManufacturing facility to a JNDI by configuring a property hibernate. session_ factory_ identify within the hibernate. properties file.

Question 279. What Are Pojos?

POJO stands for plain outdated java objects. These are simply fundamental JavaBeans which have outlined setter and getter strategies for all of the properties which might be there in that bean. Besides they will even have some business logic associated to that property. Hibernate purposes works effectively with POJOs fairly then easy java courses.

Question 280. What Is Object/relational Mapping Metadata?

ORM instruments require a metadata format for the applying to specify the mapping between courses and tables, properties and columns, associations and overseas keys, Java varieties and SQL varieties. This data known as the thing/relational mapping metadata. It defines the transformation between the totally different knowledge sort methods and relationship representations.

Question 281. What Is Hql?

HQL stands for Hibernate Query Language. Hibernate permits the person to precise queries in its personal transportable SQL extension and that is referred to as as HQL. It additionally permits the person to precise in native SQL.

Question 282. What Is Attribute Oriented Programming?

XDoclet has introduced the idea of attribute-oriented programming to Java. Until JDK 1.5, the Java language had no help for annotations; now XDoclet makes use of the Javadoc tag format (@attribute) to specify class-, field-, or method-level metadata attributes. These attributes are used to generate hibernate mapping file mechanically when the applying is constructed. This sort of programming that works on attributes known as as Attribute Oriented Programming.

Question 283. What Are The Different Methods Of Identifying An Object?

There are three strategies by which an object will be recognized.
i. Object identification –Objects are similar in the event that they reside in the identical reminiscence location within the JVM. This will be checked by utilizing the = = operator.
ii. Object equality – Objects are equal if they’ve the identical worth, as outlined by the equals( ) methodology. Classes that don’t explicitly override this methodology inherit the implementation outlined by java.lang.Object, which compares object identification.
iii. Database identification – Objects saved in a relational database are similar in the event that they signify the identical row or, equivalently, share the identical desk and first key worth.

Question 284. What Are The Different Approaches To Represent An Inheritance Hierarchy?

i. Table per concrete class.
ii. Table per class hierarchy.
iii. Table per subclass.

Question 285. What Are Managed Associations And Hibernate Associations?

Associations which might be associated to container administration persistence are referred to as managed associations. These are bi-directional associations. Coming to hibernate associations, these are unidirectional.

Question 286. Why Do You Need Orm Tool Like Hibernate?

ORM instruments like hibernate present following advantages:
• Improved efficiency: Lazy loading, Sophisticated caching, Eager loading.
• Improved productiveness: High-level object-oriented API, Less Java code to write down, No SQL to write down.
• Improved maintainability: So much much less code to write down.
• Improved portability: ORM framework generates database-specific SQL for you.

Question 287. What Are The Main Advantages Of Orm Like Hibernate?

Hibernate implements extraordinarily high-concurrency structure with no resource-contention points. This structure scales extraordinarily properly as concurrency will increase in a cluster or on a single machine.

Other efficiency associated optimizations that hibernate performs are:
• Caching objects
• Executing SQL statements later, when wanted
• Never updating unmodified objects
• Efficient Collection Handling
• Rolling two updates into one
• Updating solely the modified columns
• Outer be part of fetching
• Lazy assortment initialization
• Lazy object initialization.

Question 288. What Are The Core Interfaces Of Hibernate Framework?

1. Session Interface: The fundamental interface for all hibernate purposes. The situations are mild weighted and will be created and destroyed with out costly course of.
2. SessionManufacturing facility interface: The supply of session objects to hibernate purposes is finished by this interface. For the entire software, there shall be usually one SessionManufacturing facility and will be shared by all the applying threads.
3. Configuration Interface: Hibernate bootstrap motion is configured by this interface. The location specification is specified by particular mapping paperwork, is finished by the occasion of this interface.
4. Transaction Interface: This is an optionally available interface. This interface is used to summary the code from a transaction that’s carried out corresponding to a JDBC / JTA transaction.
5. Query and Criteria interface: The queries from the person are allowed by this interface other than controlling the stream of the question execution.

Question 289. What Is A Hibernatetemplate?

HibernateTemplate is a helper class that’s used to simplify the info entry code. This class helps mechanically converts HibernateExceptions which is a checked exception into DataAccessExceptions which is an unchecked exception. HibernateTemplate is usually used to implement knowledge entry or business logic companies. The central methodology is execute(), that helps the Hibernate code that implements HibernateCallback interface.

Question 290. What Are The Benefits Of Hibernatetemplate?

The advantages of HibernateTemplate are:
• HibernateTemplate, which is a Spring Template class, can simplify the interactions with Hibernate Sessions.
• Various widespread features are simplified into single methodology invocations.
• The classes of hibernate are closed mechanically.
• The exceptions shall be caught mechanically, and converts them into runtime exceptions.

Question 291. What Is Hibernate Proxy?

Mapping of courses will be made right into a proxy as an alternative of a desk. A proxy is returned when really a load known as on a session. The proxy incorporates precise methodology to load the info. The proxy is created by default by Hibernate, for mapping a category to a file. The code to invoke Jdbc is contained on this class.

Question 292. Explain The Types Of Hibernate Instance States.

The persistent class’s occasion will be in any one of many three totally different states. These states are outlined with a persistence context. The Hibernate has the next occasion states:
• Transient: This occasion isn’t been related to any one of many persistence course of. This doesn’t have persistent identification like major key worth.
• Persistent: A persistent context is made to affiliate with the present occasion. It has persistent identification like major key worth and a corresponding row of a desk within the knowledge base. Hibernate ensures the persistent identification is equal to the java Identity [object], for a specific persistence context.
• Detatched: This occasion affiliation with a persistence context is just as soon as and the context was closed or serialized to a different course of. The persistent identification is retained and it may be a corresponding row in a database.

Question 293. What Are Collection Types In Hibernate?

• ArrayType,
Constructor: ArrayType(String position, String propertyRef, Class factorClass, boolean isEmbeddedInXML)
• BagType,
Constructor: BagType(String position, String propertyRef, boolean isEmbeddedInXML)
• CustomizedCollectionSort, A customized sort for mapping user-written courses that implement PersistentCollection Constructor: CustomizedCollectionSort(Class userTypeClass, String position, String foreignKeyPropertyName, boolean isEmbeddedInXML)
• IdentifierBagType,
Constructor: IdentifierBagType(String position, String propertyRef, boolean isEmbeddedInXML)
• ListType,
Constructor: ListType(String position, String propertyRef, boolean isEmbeddedInXML)
• MapType,
Constructor: MapType(String position, String propertyRef, boolean isEmbeddedInXML)
• SetType
Constructor: SetType(String position, String propertyRef, boolean isEmbeddedInXML)

Question 294. What Is Lazy Initialization In Hibernate?

The delaying the thing creation or calculating a price or some course of till the primary time it’s wanted. The retrieval of explicit data solely on the time when the thing is accessed, is lazy initialization in hibernate. A situation for lazy initialization is:

When the sector creation is pricey, a area might or will not be invoked.

In this situation the creation of a area will be deferred till the precise second is come up to make use of it. The efficiency is elevated utilizing this system, by avoiding pointless creation of objects which is pricey and consumes the reminiscence area.

Question 295. What Is Lazy Fetching In Hibernate?

• Lazy setting decides whether or not to load little one objects whereas loading the Parent Object.
• This will be executed by a setting in hibernate mapping file of the guardian class.Lazy = true.
• By default the lazy loading of the kid objects is true.

Question 296. What Is The Difference Between Sorted And Ordered Collection In Hibernate?

Sorted Collection:
The sorted assortment is a group that’s sorted utilizing the Java collections framework. The sorting is finished within the reminiscence of JVM that’s operating hibernate, quickly after studying the info from the database utilizing Java Comparator.

The much less the gathering the extra the environment friendly of sorting.

Ordered Collection:
The order collections can even types a group by utilizing the order by clause for the outcomes fetched.

The extra the gathering, the extra environment friendly of sorting.

Question 297. Explain The Advantages And Disadvantages Of Detached Objects.

Advantages:
• Detached objects passing will be executed throughout layers upto the presentation layer with out utilizing Data Transfer Objects.
• At the time of utilizing lengthy transactions by the person which wants lengthy think-time, it’s prompt to separate these transactions into some transactions. The indifferent objects get modified other than the transaction scope which then will be re-attached to a brand new transaction.

Disadvantages:
• The utilization of indifferent objects are cumbersome and cryptic. It is usually recommended to not be cluttered with the session, if doable.
• It is really useful to make use of DataTransferObjects and DofundamentalObjects that’s used to keep up separation between the person interfaces and the Service.

Question 298. What Is Hibernate Query Language (hql)?

Hibernate Query Language is designed for knowledge administration utilizing Hibernate know-how. It is totally object oriented and therefore has notions like inheritance, polymorphism and abstraction. The queries are case-sensitive. This has an exception for Java courses and properties. The question operations are by objects. HQL acts as a bridge between Objects and RDBMS.

Question 299. Explain The General Flow Of Hibernate Communication With Rdbms.

The basic stream of Hibernate communication with RDBMS is :
• The Hibernate configuration is to be loaded and creation of configuration object is finished. The mapping of all hbm information shall be carried out mechanically.
• Creation of session manufacturing facility from the configuration object.
• Obtain a session from the session manufacturing facility.
• Creation of HQL Query .
• Execution of the question as a way to get the checklist of containing java objects.

Question 300. Explain The Role Of Session Interface In Hibernate.

• In hibernate, the Session interface wraps a JDBC connection, holds a compulsory (first-level) cache of persistent objects, used when navigating the thing graph or trying up objects by identifier and is a manufacturing facility for Transaction.
• Session session = sessionFactory.openSession();
• The Session interface is the first interface utilized by Hibernate purposes.
• It is a single-threaded, short-lived object representing a dialog between the applying and the persistent retailer.
• It permits you to create question objects to retrieve persistent objects.

Question 301. State The Role Of Sessionfactory Interface Plays In Hibernate.

• An software obtains Session situations from a SessionManufacturing facility which is usually single for the entire software created throughout its initialization.
• The SessionManufacturing facility caches generate SQL statements and different mapping metadata that Hibernate makes use of at runtime.
• It additionally holds cached knowledge that has been learn in a single unit of labor and could also be reused in a future unit of labor
SessionManufacturing facility sessionFactory = configuration.constructSessionManufacturing facility();

Question 302. What Is The Difference Between Merge And Update?

replace () : When the session doesn’t comprise an persistent occasion with the identical identifier, and whether it is positive use replace for the info persistence in hibernate.

merge (): Irrespective of the state of a session, if there’s a want to avoid wasting the modifications at any given time, use merge().

Question 303. What Is The Advantage Of Hibernate Over Jdbc?

The benefits of Hibernate over JDBC are:
• Hibernate code will work properly for all databases, for ex: Oracle,MySQL, and so on. the place as JDBC is database particular.
• No information of SQL is required as a result of Hibernate is a set of objects and a desk is handled as an object, the place as to work with JDBC, one must know SQL.
• Query tuning shouldn’t be required in Hibernate. The question tuning is automated in hibernate by utilizing standards queries, and the results of efficiency is at its finest. Where as in JDBC the question tuning is to be executed by the database authors.
• With the help of cache of hibernate, the info will be positioned within the cache for higher efficiency. Where as in JDBC the java cache is to be carried out.

Question 304. Why Hibernate Is Advantageous Over Entity Beans & Jdbc?

An entity bean at all times works below the EJB container, which permits reusing of the thing exterior to the container. An object cannot be indifferent in entity beans and in hibernate indifferent objects are supported.

Hibernate shouldn’t be database dependent the place as JDBC is database dependent. Query tuning shouldn’t be wanted for hibernate as JDBC is required. Data will be positioned in a number of cache which is supported by hibernate, whereas in JDBC the cache is to be carried out.

Question 305. Explain The Main Difference Between Entity Beans And Hibernate.

Entity beans are to be carried out by containers, courses, descriptors. Hibernate is only a software that shortly persist the thing tree to a category hierarchy in a database and with out utilizing a single SQL assertion. The inheritance and polymorphism is kind of merely carried out in hibernate which is out of the field of EJB and an enormous downside.

Question 306. Explain The Difference Between Hibernate And Spring.

Hibernate is an ORM software for knowledge persistency. Spring is a framework for enterprise purposes. Spring helps hibernate and gives the totally different courses that are templates that incorporates the widespread code.

Question 307. How Will You Configure Hibernate?

The configuration information hibernate.cfg.xml (or hibernate.properties) and mapping information *.hbm.xml are utilized by the Configuration class to create (i.e. configure and bootstrap hibernate) the SessionManufacturing facility, which in flip creates the Session situations. Session situations are the first interface for the persistence service.

” hibernate.cfg.xml (alternatively can use hibernate.properties): These two information are used to configure the hibernate sevice (connection driver class, connection URL, connection username, connection password, dialect and so on). If each information are current within the classpath then hibernate.cfg.xml file overrides the settings discovered within the hibernate.properties file.

” Mapping information (*.hbm.xml): These information are used to map persistent objects to a relational database. It is the most effective follow to retailer every object in a person mapping file (i.e mapping file per class) as a result of storing giant variety of persistent courses into one mapping file will be troublesome to handle and preserve. The naming conference is to make use of the identical identify because the persistent (POJO) class identify. For instance Account.class can have a mapping file named Account.hbm.xml. Alternatively hibernate annotations can be utilized as a part of your persistent class code as an alternative of the *.hbm.xml information.

Question 308. What Is A Sessionfactory? Is It A Thread-safe Object?

SessionManufacturing facility is Hibernates idea of a single datastore and is threadsafe in order that many threads can entry it concurrently and request for classes and immutable cache of compiled mappings for a single database. A SessionManufacturing facility is often solely constructed as soon as at startup. SessionManufacturing facility must be wrapped in some sort of singleton in order that it may be simply accessed in an software code.
SessionManufacturing facility sessionFactory = new Configuration().configure().constructSessionfactory();

Question 309. What Is A Session? Can You Share A Session Object Between Different Theads?

Session is a lightweight weight and a non-threadsafe object (No, you can not share it between threads) that represents a single unit-of-work with the database. Sessions are opened by a SessionManufacturing facility after which are closed when all work is full. Session is the first interface for the persistence service. A session obtains a database connection lazily (i.e. solely when required). To keep away from creating too many classes ThreadNative class can be utilized as proven beneath to get the present session regardless of what number of occasions you make name to the presentSession() methodology.
&
public class HibernateUtil {
&
public static last ThreadNative native = new ThreadNative();
public static Session presentSession() throws HibernateException {
Session session = (Session) native.get();
//open a brand new session if this thread has no session
if(session == null)
session = sessionFactory.openSession();
native.set(session);

return session;
}
}
It can be important that you simply shut your session after your unit of labor completes.

Question 310. What Are The Benefits Of Detached Objects?

Detached objects will be handed throughout layers all the way in which as much as the presentation layer with out having to make use of any DTOs (Data Transfer Objects). You can afterward re-attach the indifferent objects to a different session.

Question 311. What Are The Pros And Cons Of Detached Objects?

Pros:
” When lengthy transactions are required as a result of person think-time, it’s the finest follow to interrupt the lengthy transaction up into two or extra transactions. You can use indifferent objects from the primary transaction to hold knowledge all the way in which as much as the presentation layer. These indifferent objects get modified outdoors a transaction and afterward re-attached to a brand new transaction by way of one other session.
Cons
” In basic, working with indifferent objects is kind of cumbersome, and higher to not litter up the session with them if doable. It is best to discard them and re-fetch them on subsequent requests. This method shouldn’t be solely extra transportable but in addition extra environment friendly as a result of – the objects cling round in Hibernate’s cache anyway.
” Also from pure wealthy area pushed design perspective it is suggested to make use of DTOs (DataTransferObjects) and DOs (DofundamentalObjects) to keep up the separation between Service and UI tiers.

Question 312. How Does Hibernate Distinguish Between Transient (i.e. Newly Instantiated) And Detached Objects?

Hibernate makes use of the model property, if there may be one.

If not makes use of the identifier worth. No identifier worth means a brand new object. This does work just for Hibernate managed surrogate keys. Does not work for pure keys and assigned (i.e. not managed by Hibernate) surrogate keys.

Write your personal technique with Interceptor.isUnsaved().

Question 313. What Is The Difference Between The Session.get() Method And The Session.load() Method?

Both the session.get(..) and session.load() strategies create a persistent object by loading the required object from the database. But if there was not such object within the database then the strategy session.load(..) throws an exception whereas session.get(&) returns null.

Question 314. What Is The Difference Between The Session.replace() Method And The Session.lock() Method?

Both of those strategies and saveOrUpdate() methodology are meant for reattaching a indifferent object. The session.lock() methodology merely reattaches the article to the session with out checking or updating the database on the idea that the database in sync with the indifferent object. It is one of the best apply to make use of both session.replace(..) or session.saveOrUpdate(). Use session.lock() solely in case you are completely positive that the indifferent object is in sync together with your indifferent object or if it doesn’t matter as a result of you may be overwriting all of the columns that might have modified in a while throughout the similar transaction. Note: When you reattach indifferent objects it’s good to guarantee that the dependent objects are reatched as properly.

Question 315. How Would You Reatach Detached Objects To A Session When The Same Object Has Already Been Loaded Into The Session?

You can use the session.merge() methodology name.

Question 316. What Are The General Considerations Or Best Practices For Defining Your Hibernate Persistent Classes?

1.You will need to have a default no-argument constructor on your persistent courses and there needs to be getXXX() (i.e accessor/getter) and setXXX( i.e. mutator/setter) strategies for all of your persistable occasion variables.
2.You ought to implement the equals() and hashCode() strategies primarily based in your business key and it’s important to not use the id area in your equals() and hashCode() definition if the id area is a surrogate key (i.e. Hibernate managed identifier). This is as a result of the Hibernate solely generates and units the sector when saving the article.
3. It is really helpful to implement the Serializable interface. This is probably helpful if you wish to migrate round a multi-processor cluster.
4.The persistent class shouldn’t be last as a result of whether it is last then lazy loading can’t be utilized by creating proxy objects.
5.Use XDoclet tags for producing your *.hbm.xml information or Annotations (JDK 1.5 onwards), that are much less verbose than *.hbm.xml information.

Question 317. How Will You Communicate Between Two Applets?

The easiest methodology is to make use of the static variables of a shared class since there’s just one occasion of the category and therefore just one copy of its static variables. A barely extra dependable methodology depends on the truth that all of the applets on a given web page share the identical AppletContext. We get hold of this applet context as follows:

AppletContext ac = getAppletContext();

AppletContext offers applets with strategies comparable to getApplet(identify), getApplets(),getAudioClip, getImage, presentDocument and showStatus().

Question 318. How Do You Communicate In Between Applets And Servlets?

We can use the java.web.URLConnection and java.web.URL courses to open a normal HTTP connection and “tunnel” to the net server. The server then passes this info to the servlet within the regular means. Basically, the applet pretends to be an online browser, and the servlet does not know the distinction. As far because the servlet is anxious, the applet is simply one other HTTP shopper.

Question 319. What Is An Applet? Should Applets Have Constructors?

Applets are small applications transferred by Internet, robotically put in and run as a part of web-browser. Applets implements performance of a shopper. Applet is a dynamic and interactive program that runs inside a Web web page displayed by a Java-capable browser. We dont have the idea of Constructors in Applets. Applets might be invoked both by browser or by Appletviewer utility supplied by JDK.

Question 320. How Will You Initialize An Applet?

Write my initialization code within the applets init methodology or applet constructor.

Question 321. How To Insert Your Applets Into Frontpage?

1. Place the .class file within the listing containing the HTML doc into which you need to insert the applet.
2. Copy the <applet>…</applet> tag out of your applet implementation or examples to the clipboard.
3. In EntrancePage choose the “HTML” tab from the decrease left hand nook.
4. Paste the <applet>…</applet> tag in an applicable place between the <physique> and </physique> tags. You’ll discover a grey field with the aqua letter “J” within the “Normal” view indicating the the applet tag has been inserted.
5. To see the applet look choose the “Preview” tab.

Question 322. In Our Urls And In The Text Of The Buttons We Have Comma. Its Causing An Error. Is There A Way To Change The Delimiting Character For The Menu Arguments?

Since 2.00 model our applets assist an user-defined delimiter for the menu arguments. To modify the default delimiter add the next parameter (you should utilize any character as a delimiter):

<param identify=”delimiter” worth=”~”>
and use it inside “menuItems”:
<param identify=”menuItems” worth=”
{Home~http://www.wisdomjobs.com.com/index.php}
{Features,Setup~http://www.wisdomjobs.com/}
“>
Question 323. What Is The Order Of Method Invocation In An Applet?

► public void init() : Initialization methodology known as as soon as by browser.
► public void begin() : Method known as after init() and comprises code to start out processing. If the consumer leaves the web page and returns with out killing the present browser session, the beginning () methodology known as with out being preceded by init ().
► public void cease() : Stops all processing began by begin (). Done if consumer strikes off web page.
► public void destroy() : Called if present browser session is being terminated. Frees all sources utilized by applet.

Question 324. What Are The Applets Life Cycle Methods? Explain Them?

strategies within the life cycle of an Applet:
► init() methodology – known as when an applet is first loaded. This methodology known as solely as soon as in the complete cycle of an applet. This methodology often intialize the variables for use within the applet.
► begin( ) methodology – known as every time an applet is began.
► paint() methodology – known as when the applet is minimized or refreshed. This methodology is used for drawing completely different strings, figures, and pictures on the applet window.
► cease( ) methodology – known as when the browser strikes off the applets web page.
► destroy( ) methodology – known as when the browser is completed with the applet.

Question 325. What Is The Sequence For Calling The Methods By Awt For Applets?

When an applet begins, the AWT calls the next strategies, on this sequence:
► init()
► begin()
► paint()
When an applet is terminated, the next sequence of methodology calls takes place :
► cease()
► destroy()

Question 326. How Do Applets Differ From Applications?

Following are the principle variations:
Application: Stand Alone, doesnt want web-browser.
Applet: Needs no express set up on native machine. Can be transferred by Internet on to the native machine and will run as a part of web-browser.
Application: Execution begins with foremost() methodology. Doesnt work if foremost isn’t there.
Applet: Execution begins with init() methodology.
Application: May or might not be a GUI.
Applet: Must run inside a GUI (Using AWT). This is important function of applets.

Question 327. Can We Pass Parameters To An Applet From Html Page To An Applet? How?

We can go parameters to an applet utilizing <param> tag within the following means:

► <param identify=param1″ worth=value1″>
► <param identify=param2″ valuevalue2″>

Access these parameters contained in the applet is completed by calling getParameter() methodology contained in the applet. Note that getParameter() methodology returns String worth similar to the parameter identify.

Question 328. How Do We Read Number Information From My Applets Parameters, Given That Applets Getparameter() Method Returns A String?

Use the parseInt() methodology within the Integer Class, the Float(String) constructor or parseFloat() methodology within the Class Float, or the Double(String) constructor or parseDoulbl() methodology within the class Double.

Question 329. How Can I Arrange For Different Applets On A Web Page To Communicate With Each Other?

Name your applets contained in the Applet tag and invoke AppletContexts getApplet() methodology in your applet code to acquire references to the opposite applets on the web page.

Question 330. 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 presentDocument() on that context object.

URL targetURL;
String URLString
AppletContext context = getAppletContext();
attempt
{
targetURL = new URL(URLString);
}
catch (MalformedURLException e)

// Code for get better from the exception

context. presentDocument (targetURL);

Question 331. Can Applets On Different Pages Communicate With Each Other?

Use the getSize() methodology, which the Applet class inherits from the Component class within the Java.awt package deal. The getSize() methodology returns the dimensions of the applet as a Dimension object, from which you extract separate width, top fields. The following code snippet explains this:
Dimension dim = getSize();
int appletwidth = dim.width();
int appletheight = dim.top();

Question 332. Which Classes And Interfaces Does Applet Class Consists?

Applet class consists of a single class, the Applet class and three interfaces: AppletContext, AppletStub, and AudioClip.

Question 333. What Is Appletstub Interface?

The applet stub interface offers the means by which an applet and the browser talk. Your code won’t usually implement this interface.

Question 334. What Are The Applets Information Methods?

The following are the Applets info strategies: getAppletInfo() methodology: Returns a string describing the applet, its creator, copyright info, and many others. getParameterInfo() methodology: Returns an array of string describing the applets parameters.

Question 335. What Are The Steps Involved In Applet Development?

Following are the steps concerned in Applet growth:
► Create/Edit a Java supply file. This file should comprise a category which extends Applet class.
► Compile your program utilizing javac
► Execute the appletviewer, specifying the identify of your applets supply file or html file. In case the applet info is saved in html file then Applet might be invoked utilizing java enabled internet browser.

Question 336. Which Method Is Used To Output A String To An Applet? Which Function Is This Method Included In?

drawString( ) methodology is used to output a string to an applet. This methodology is included within the paint methodology of the Applet.

Question 337. When Is Update Method Called?

Whenever a display screen wants redrawing (e.g., upon creation, resizing, validating) the replace methodology known as. By default, the replace methodology clears the display screen after which calls the paint methodology, which usually comprises all of the drawing code.

Question 338. What Is A Message Driven Bean, What Functions Does A Message Driven Bean Have And How Do They Work In Collaboration With Jms?

Message pushed beans are the newest addition to the household of part bean sorts outlined by the EJB specification. The unique bean sorts embody session beans, which comprise business logic and keep a state related to shopper periods, and entity beans, which map objects to persistent information. Message pushed beans will present asynchrony to EJB primarily based purposes by appearing as JMS message shoppers. A message bean is related to a JMS matter or queue and receives JMS messages despatched by EJB purchasers or different beans. Unlike entity beans and session beans, message beans wouldn’t have house or distant interfaces. Instead, message pushed beans are instantiated by the container as required. Like stateless session beans, message beans keep no client-specific state, permitting the container to optimally handle a pool of message-bean situations. Clients ship JMS messages to message beans in precisely the identical method as they’d ship messages to every other JMS vacation spot. This similarity is a elementary design purpose of the JMS capabilities of the brand new specification. To obtain JMS messages, message pushed beans implement the javax.jms.MessageListener interface, which defines a single onMessage() methodology. When a message arrives, the container ensures {that a} message bean similar to the message matter/queue exists (instantiating it if crucial), and calls its onMessage methodology passing the shopper’s message as the only argument. The message bean’s implementation of this methodology comprises the business logic required to course of the message. Note that session beans and entity beans aren’t allowed to perform as message beans.

Question 339. How Does Concurrency Work For Message-driven Beans?

The means concurrency is achieved for Queues is by spawning one JMSSession per MDB occasion within the pool. Since JMSSessions are processed in parallel by JMS, concurrency is obtained naturally this manner and JMS takes care of delivering the message to, at most, one listener. If an MDB is deployed to a number of servers in a cluster, JMSSessions are created for every MDB occasion on every server and cargo balancing might be finished throughout them. For Topics in WebLogic JMS 6.1, there may be one JMSSession per bean occasion within the pool. Because of the best way Topics work, the session, and thus each bean occasion, receives a duplicate of every message revealed on that Topic. (There was additionally an issue that brought on parallel processing to not work appropriately. This has been mounted for WLS 6.0 Service Pack 1.) Within a single server, one matter client is used to go out messages to a number of threads to get the concurrency whereas producing solely a single copy of every message. You can configure a number of MDBs to pay attention on the identical matter and every MDB will obtain a duplicate of each message. When utilizing a number of servers, every server will get its personal client and subsequently its personal copy of every message. It isn’t at the moment attainable to share a client throughout a number of servers. If you desire a message to be processed by precisely one MDB, use a queue. One buyer had an instance the place matter MDBs are wanted during which there might be a number of implementations of the MDBs listening on the identical matter. In different phrases, multiple MDB with a unique implementation could also be subscribing to the identical matter. The shopper has no superior means of figuring out what number of completely different sorts of MDBs could also be listening on the identical matter, however it’s attainable for there to be multiple listener, subsequently matters, not queues. For every form of MDB listening on the subject, the message is delivered precisely as soon as (i.e., the message might be delivered precisely as soon as to an occasion in every named MDB pool listening on the subject).

Question 340. What Is The Difference Between Message Driven Beans And Stateless Session Beans?

In a number of methods, the dynamic creation and allocation of message-driven bean situations mimics the conduct of stateless session EJB situations, which exist solely throughout a selected methodology name. However, message-driven beans are completely different from stateless session EJBs (and different forms of EJBs) in a number of vital methods: Message-driven beans course of a number of JMS messages asynchronously, slightly than processing a serialized sequence of methodology calls. Message-driven beans don’t have any house or distant interface, and subsequently can’t be immediately accessed by inner or exterior purchasers. Clients work together with message-driven beans solely not directly, by sending a message to a JMS Queue or Topic.

Only the container immediately interacts with a message-driven bean by creating bean situations and passing JMS messages to these situations as crucial. The Container maintains the complete lifecycle of a message-driven bean; situations can’t be created or eliminated on account of shopper requests or different API calls.

Question 341. What Is Message Driven Beam?

An enterprise bean that’s an asynchronous message client. A message-driven bean has no state for a selected shopper, however its occasion variables can comprise state throughout the dealing with of shopper messages, together with an open database connection and an object reference to an EJB object. A shopper accesses a message-driven bean by sending messages to the vacation spot for which the bean is a message listener.

Question 342. What Is Session Bean. What Are The Various Types Of Session Bean?

SessionBeans usually are used to signify a shopper they’re of two sorts:

Stateful Session Beans : they keep conversational state between subsequest calls by a shopper.
Stateless Session Bean : contemplate this as a servlet equal in EJB. It is simply used to service purchasers no matter state and doesn’t keep any state.

Question 343. What Is The Difference Between Stateful Session Bean And Stateless Session Bean

Stateful session beans have the passivated and Active state which the Stateless bean doesn’t have.

Question 344. What Are The Call Back Methods In Session Bean?

Session bean callback strategies differ whether or not it’s Stateless or stateful Session bean they’re.

Stateless Session Bean
1. setSessionContext()
2. ejbCreate()
3. ejbRemove()

Stateful Session Bean
1. setSessionContext()
2.ejbCreate()
3.ejbPassivate()
4.ejbActivate()
5.ejbRemove()

Question 345. When You Will Chose Stateful Session Bean And Stateless Session Bean

stateful session bean is used when we have to keep the shopper state . Where stateless session bean won’t have a shopper state it is going to be in pool. Example of statefull session is Shoping cart web site the place we have to keep the shopper state .

Question 346. What Is The Relationship Between Enterprise Javabeans And Javabeans?

Enterprise JavaBeans extends the JavaBeans part mannequin to deal with the wants of transactional business purposes.

JavaBeans is a part mannequin for visible building of reusable elements for the Java platform. Enterprise JavaBeans extends JavaBeans to middle-tier/server facet business purposes. The extensions that Enterprise JavaBeans provides to JavaBeans embody assist for transactions, state administration, and deployment time attributes.

Although purposes deploying the Enterprise JavaBeans structure are unbiased from the underlying communication protocol, the Enterprise JavaBeans structure specifies how communication amongst elements maps into the underlying communication protocols, comparable to CORBA/IIOP.

Question 347. How To Implement A Bound Property In Your Bean Application?

To implement a certain property within the utility, comply with these steps:
► Import the java.beans package deal. This offers you entry to the PropertyChangeAssist class.
► Instantiate a PropertyChangeAssist object. This object maintains the property change listener checklist and fires property change occasions. You may make your class a PropertyChangeAssist subclass.
► Implement strategies to take care of the property change listener checklist. Since a PropertyChangeAssist subclass implements these strategies, you merely wrap calls to the property-change assist object’s strategies.
► Modify a property’s set methodology to fireside a property change occasion when the property is modified.

Question 348. How And When Will The Javabeans Migration Assistant To Activex Be Available?

IBM plans to ship the JavaBeans Migration Assistant for ActiveX in Taligent’s Visual Age, WebRunner Toolkit, and Visual Age for Java growth instruments. This will enable builders to make the most of a typical part mannequin which may be leveraged by a variety of instruments, together with the IBM Visual Age for Java household.

Question 349. Why Would A Developer Need The Javabeans Migration Assistant For Activex?

Many of the capabilities which can be so thrilling to JavaBeans builders aren’t obtainable on ActiveX, or are incomplete. There is, subsequently, a necessity for a set of conversion conventions and instruments designed to transform desktop ActiveX elements into JavaBeans elements. The ensuing Beans might be usable in each in new community savvy e-business purposes in addition to conventional desktop purposes, together withActiveX containers. Developers and prospects profit from the benefits provided by JavaBeans by merely leveraging their present investments in ActiveX.

Question 350. Can Javabeans Use Dcom As Its Network Model?

JavaBeans works with any community mannequin (i.e., to speak between elements throughout the community), together with CORBA, DCOM, and many others. JavaBeans integrates properly with CORBA IDL, which is a wonderful resolution for purchasers in a heterogeneous distributed computing atmosphere with platform unbiased elements. However, we advocate RMI for Java to Java inter-object communication.

Question 351. Can Both Java Applets And Javabeans Components Use The Infobus?

Yes.

Question 352. Javabeans Has Mechanisms Like Bound Properties For Data Transfer Between Components. Why Is The Infobus Necessary?

JavaBeans mechanisms, comparable to certain properties, are very helpful in circumstances the place the kind of information to be communicated might be hard-coded into the supply and goal elements. The InfoBus provides further options required for extra dynamic information interchange. These might be circumstances the place communication is pushed by the content of the information and the place the character of the information to be exchanged is set at runtime.

Question 353. Is Infobus Easy To Use?

Using InfoBus conscious elements, such because the ESuite elements from Lotus, customers can simply assemble highly effective information pushed purposes. No programming or scripting is required: easy parameters are used to ascertain connections to databases and to pick information for processing. For builders creating InfoBus elements, InfoBus affords an easy API suitable in type with different options of JavaBeans.

Question 354. Does The Infobus Compete With Javabeans?

On the opposite, InfoBus extends the ability of JavaBeans to a brand new vary of extra dynamic purposes. InfoBus is totally suitable with JavaBeans, and Lotus enthusiastically helps JavaBeans because the part customary for Java. Wherever attainable, InfoBus makes use of the prevailing mechanisms of JavaBeans.

Question 355. What Is The Infobus?

The InfoBus is a compact Java API which permits cooperating applets or Beans, on a Web web page or in every other Java utility, to speak information to 1 one other. The InfoBus structure allows Beans to be categorized as “information suppliers” and “information shoppers”. Data suppliers are Beans whose main perform is to entry information from their native retailer, comparable to a DBMS, spreadsheet, flat file, Lotus Notes database and many others., and to supply information onto the InfoBus.

Data shoppers retrieve information from the bus, for evaluation or visible show. This segregation of supplier from client is extraordinarily highly effective in that it allows purposes to be unbiased of their information; for instance, a charting Bean needn’t perceive SQL or JDBC with a purpose to entry DBMS information.

Of course, a Bean might be each a client and supplier: for instance a spreadsheet could settle for information from a DBMS and supply information to a chart Bean.

Question 356. What Are/is Enterprise Javabeans?

Enterprise JavaBeans (EJB) is an API specification for constructing scalable, distributed, component-based, multi-tier purposes. It leverages and extends the JavaBeans part mannequin to supply a wealthy object-oriented transactional atmosphere for builders constructing enterprise purposes.

Enterprise JavaBeans (EJB) know-how is the premise of Java 2 Platform, Enterprise Edition (J2EE). EJB know-how offers the scalable structure for executing business logic in a distributed computing atmosphere. J2EE makes the lifetime of an enterprise developer simpler by combining the EJB part structure with different enterprise applied sciences to options on the Java platform for seamless growth and deployment of server facet purposes.

Question 357. Who Is Developing The Javabeans Migration Assistant To Activex?

IBM and Taligent, its object oriented know-how subsidiary, with assist from JavaMushy, are creating a set of conversion conventions, a porting information and power that can enable builders to simply convert their Windows ActiveX elements into JavaBeans.

Question 358. Why Is The Javabeans Bridge For Activex Only Available On Windows/x86?

Sun’s JavaBeans Bridge for ActiveX is platform particular as a result of platform particular nature of ActiveX. Currently, ActiveX is basically a Window/X86 platform particular part structure.

If Microsoft delivers ActiveX libraries and ActiveX purposes on different platforms, Sun will consider buyer demand and reply accordingly.

Question 359. What Is The Relation Between The Infobus And Rmi?

The InfoBus structure addresses Beans speaking to 1 in a single JVM not throughout a number of JVMs; whereas RMI (Remote Method Invocation) is meant for communication throughout JVMs (completely different Java Virtual Machines throughout the community). As for IIOP, one can envision a JavaBeans part that makes use of RMI to speak to one thing on one other JVM after which publishes the information on the InfoBus.

Additionally, RMI might be used to permit elements in several safety courses to speak throughout the similar JVM.

Question 360. Difference Between Java Beans And Enterprise Java Beans?

JavaBeans could also be seen or nonvisible at runtime.For instance, the visible GUI part could also be a button,checklist field,graphic or a chart. An EJB is a nonvisual ,distant object.
JavaBeans are meant to be native to a single course of and are primarly meant to run on the shopper facet.Although one can develop server-side JavaBeans,it’s far simpler to develop them utilizing the EJB specification as a substitute. EJB’s are remotely executable elements or business objects that may be deployed solely on the server.
JavaBeans is a part know-how to create generic Java elements that may be composed collectively into applets and purposes.
Even although EJB is a part know-how,it neither builds upon nor extends the unique JavaBean specification.
JavaBeans have an exterior interface known as the properties interface, which permits a builder instrument to interpret the performance of the bean. EJBs have a dployement descriptor that describes its performance to an exterior builder instrument or IDE
JavaBeans could have BeanInfo courses,property editors or customizers.

Question 361. Is The Infobus Client Side Only?

Yes. InfoBus is often used to speak amongst Beans on the shopper, and it can be helpful for sharing info amongst elements at a single server web site. The preliminary model of InfoBus isn’t distributed, and is subsequently not meant for transmission of knowledge between purchasers and servers.

A wide range of Java communication providers, together with JDBC, CORBA, and RMI can be utilized by InfoBus elements for entry to distributed information. For instance, the ESuite Data Access part is a Bean that connects any JDBC compliant information supply to the InfoBus. Once the information is on the bus, it will possibly simply be imported by any InfoBus Data Consumer, comparable to a spreadsheet, chartingcomponent, phrase processor or information evaluation instrument.

Question 362. Will The General Public Have Access To The Infobus Apis?

Yes, underneath the same old phrases of the JDK license. The specification and know-how preview can be found in our merchandise archive.

Question 363. How Does The Infobus Relate To Javabeans?

The InfoBus specification extends JavaBeans by offering a set of enhanced interfaces to share and alternate dynamic information.

Question 364. What Is Glasgow?

Glasgow – the code identify for add-ins to the JavaBeans specification. It comprises following specs:
► The Extensible Runtime Containment and Services Protocol.
► The Drag and Drop Subsystem for the Java Foundation Classes.
► The JavaBeans Activation Framework.

Question 365. How To Create Bound Property In Bean Application?

To create the title property as a certain property for the MyBean part within the InternetBeans GUI Builder, carry out the next sequence of operations:

Right-click the Bean Patterns node within the MyBean class hierarchy.
Select Add|Property from the pop-up menu.
Fill the New Property Pattern type and click on OK.

Question 366. What Is The Serializable Class In Java Beans?

Any class is serializable so long as that class or a mother or father class implements the java.io.Serializable interface. Examples of serializable courses embody Component, String, Date, Vector, and Hashtable.

Question 367. How To Control Serialization In Java Beans?

Three methods to manage serilization in java beans:
1.Automatic serialization, carried out by the Serializable interface. The Java serialization software program serializes the complete object, besides transient and static fields.
2.Customized serialization. Selectively exclude fields you do not need serialized by marking with the transient (or static) modifier.
3.Customized file format, carried out by the Externalizable interface and its two strategies. Beans are written in a selected file format.

Question 368. What Is Introspection Properties In Java Beans?

Introspection is the automated strategy of analyzing a bean’s design patterns to disclose the bean’s properties, occasions, and strategies.

Question 369. What Are Introspection Api In Java Beans?

The JavaBeans API structure provides a set of courses and interfaces to supply introspection. The BeanInfo (within the API reference documentation) interface of the java.beans package deal defines a set of strategies that enable bean implementors to supply express details about their beans. By specifying BeanInfo for a bean part, a developer can cover strategies, specify an icon for the toolbox, present descriptive names for properties, outline which properties are certain properties, and far more.

The getBeanInfo(beanName) (within the API reference documentation) of the Introspector (within the API reference documentation) class can be utilized by builder instruments and different automated environments to supply detailed details about a bean. The getBeanInfo methodology depends on the naming conventions for the bean’s properties, occasions, and strategies. A name to getBeanInfo leads to the introspection course of analyzing the bean?s courses and superclasses.

Question 370. What Is Bean Customization?

Customization offers a way for modifying the looks and habits of a bean inside an utility builder so it meets your particular wants. There are a number of ranges of customization accessible for a bean developer to permit different builders to get most profit from a bean?s potential performance.

1.By utilizing a property editor. Each bean property has its personal property editor. The InternetBeans GUI Builder normally shows a bean’s property editors within the Properties window. The property editor that’s related to a specific property sort edits that property sort.
2. By utilizing customizers. Customizers provide you with full GUI management over bean customization. Customizers are used the place property editors will not be sensible or relevant. Unlike a property editor, which is related to a property, a customizer is related to a bean.

Question 371. What Is Ejb Container?

A container that implements the EJB part contract of the J2EE structure. This contract specifies a runtime setting for enterprise beans that features safety, concurrency, life-cycle administration, transactions, deployment, naming, and different providers. An EJB container is supplied by an EJB or J2EE server.

Question 372. What Is Ejb Context?

A vendor that provides an EJB container. An object that enables an enterprise bean to invoke providers supplied by the container and to acquire the details about the caller of a client-invoked methodology.

Question 373. What Is Ejb Home Object?

An object that gives the life-cycle operations (create, take away, discover) for an enterprise bean. The class for the EJB Home object is generated by the container’s deployment instruments. The EJB Home object implements the enterprise bean’s Home interface. The shopper references an EJB Home object to carry out life-cycle operations on an EJB object. The shopper makes use of JNDI to find an EJB Home object.

Question 374. What Is Ejb Object?

An object whose class implements the enterprise bean’s distant interface. A shopper by no means references an enterprise bean occasion immediately. A shopper all the time references an EJB object. The class of an EJB object is generated by a container’s deployment instruments.

Question 375. What Is Entity Bean?

An enterprise bean that represents persistent information maintained in a database. An entity bean can handle its personal persistence or can delegate this operate to its container. An entity bean is recognized by a main key. If the container by which an entity bean is hosted crashes, the entity bean, its main key, and any distant references survive the crash.

Question 376. What Is Ejb Server?

Software that gives providers to an EJB container. For instance, an EJB container sometimes depends on a transaction supervisor that’s a part of the EJBserver to carry out the two-phase commit throughout all of the collaborating useful resource managers. The J2EE structure assumes that an EJB container is hosted by an EJBserver from the identical vendor, so it doesn’t specify the contract between these two entities. An EJB server can host a number of EJB containers.

Question 377. What Is Enterprise Information System?

The functions that represent an enterprise’s present system for dealing with companywide info. These functions present an info infrastructure for an enterprise. An enterpriseinformation system presents a well-defined set of providers to its shoppers. These providers are uncovered to shoppers as native or distant interfaces or each. Examples of enterprise info programs embrace enterprise useful resource planning programs, mainframe transaction processing programs, and legacy database programs.

Question 378. What Is Enterprise Javabeans?

A part structure for the event and deployment of object-oriented, distributed, enterprise-level functions. Applications written utilizing the Enterprise JavaBeans structure are scalable, transactional, and safe.

Question 379. What Is Enterprise Javabeans Query Language?

Defines the queries for the finder and choose strategies of an entity bean having container-managed persistence. A subset of SQL92, EJB QL has extensions that permit navigation over the relationships outlined in an entity bean’s summary schema.

Question 380. What Is Enterprise Bean Provider?

An utility developer who produces enterprise bean lessons, distant and Interview Questions – Home interfaces, and deployment descriptor information, and packages them in an EJB JAR file.

Question 381. What Is An Entity?

A definite, particular person merchandise that may be included in an XML doc by referencing it. Such an entity reference can title an entity as small as a personality (for instance, <, which references the less-than image or left angle bracket, <). An entity reference also can reference a whole doc, an exterior entity, or a set of DTD definitions.

Question 382. What Is Entity Reference?

A reference to an entity that’s substituted for the reference when the XML doc is parsed. It can reference a predefined entity resembling or reference one that’s outlined within the DTD. In the XML information, the reference might be to an entity that’s outlined within the native subset of the DTD or to an exterior XML file (an exterior entity). The DTD also can carve out a section of DTD specs and provides it a reputation in order that it may be reused (included) at a number of factors within the DTD by defining a parameter entity.

Question 383. What Are The Security Implications For Downloading Beans Over The Internet?

JavaBeans doesn’t add any safety features to the Java platform. Rather, JavaBeans elements have full entry to the broad vary of safety features which might be a part of the Java platform. JavaBeans elements can be utilized to construct a variety of various sorts of options from full-fledged Java desktop functions to web-based Applets.

Question 384. Why Do I Get A Duplicate Name Error When Loading A Jar File?

The commonest purpose for a “java.lang.ClassFormatError: Duplicate title” error is {that a} .class file within the JAR accommodates a category whose class title is totally different from the anticipated title. So for instance when you have a file known as “a/B.class” and it accommodates a category known as “B” or “a.X” as a substitute of the category “a.B” then you’ll get this error.

The commonest causes for this downside are both forgetting to incorporate a “bundle a;” assertion or having a “bundle” assertion with the fallacious title.

Question 385. What Is The Relationship Between Sun S Jfcs And Javabeans?

The JFC (Java Foundation Classes) relies upon the AWT (Abstract Windowing Toolkit), which has been a part of the Java platform from the start. JFC successfully provides a richer set of visible components for constructing JavaBeans elements and functions. See the JFC website for extra info.

Question 386. Are There Javabeans Components Available That I Can Buy Today?

Yes. Numerous firms, each massive and small, have introduced their plans to ship JavaBeans-based merchandise.

Question 387. What Kind Of Industry Support Exists For Javabeans?

A coalition of trade leaders in part growth labored with JavaSoft to create the JavaBeans specification, which was launched to the Internet for public feedback on September 4, 1996. The “frozen” JavaBeans specification combines the work of Apple, Borland, IBM, SimplySystem, Microsoft, Netscape, Rogue Wave, SunSoft and Symantec and plenty of, many others… We’re more than happy to see the instruments neighborhood swiftly embracing JavaBeans by asserting assist for JavaBeans of their visible utility builder instruments.

Question 388. Why A Component Architecture For The Java Platform?

JavaBeans brings the extraordinary energy of the Java platform to part growth, providing the perfect setting for a developer who desires to increase the idea of reusable part growth past one platform and one structure to embrace each platform and each structure within the trade.

Question 389. Is Javabeans A Complete Component Architecture?

JavaBeans is an entire part mannequin. It helps the usual part structure options of properties, occasions, strategies, and persistence. In addition, JavaBeans offers assist for introspection (to permit automated evaluation of a JavaBeanspart) and customization (to make it straightforward to configure a JavaBeans part).

Question 390. Why Are Component Architectures Useful?

Developers are turning to creating elements fairly than monolithic functions to free themselves from gradual, costly utility growth, and to construct up a transportable, reusable code base. This permits builders to rapidly assault new market alternatives, new joint growth alternatives, and new methods to promote smaller packages of software program.

Question 391. What Is A Bean? Why Is Not A Bean An Applet?

JavaBeans elements, or Beans, are reusable software program elements that may be manipulated visually in a builder device. Beans might be mixed to create conventional functions, or their smaller web-oriented brethren, applets. In addition, applets might be designed to work as reusable Beans.

Individual Beans will operate fairly in a different way, however typical unifying options that distinguish a Bean are:
► Introspection: permits a builder device to investigate how a Bean works.
► Customization: permits a developer to make use of an app builder device to customise the looks and habits of a Bean.
► Events: permits Beans to speak and join collectively.
► Properties: allow builders to customise and program with Beans.
► Persistence: permits builders to customise Beans in an app builder, after which retrieve these Beans, with custom-made options intact, for future use.

Question 392. Difference Between Java Bean And Bean?

A Java Bean is a software program part written within the Java programming language that conforms to the JavaBeans part specification. The JavaBeans APIs turned a part of the “core” Java APIs as of the 1.1 launch of the JDK. The JavaBeans specification defines a Java-based software program part mannequin that provides quite a lot of options to the Java programming language. Some of those options embrace:

► introspection
► customization
► occasions
► properties
► persistence

Enterprise JavaBeans (EJBs) are Java-based software program elements which might be constructed to adjust to Java’s EJB specification and run inside an EJB container equipped by a J2EE supplier. An EJB container offers distributed utility performance resembling transaction assist, persistence and lifecycle administration for the EJBs.

Question 393. Write A Simple Bean Program?

Write the SimpleBean code. Put it in a file named SimpleBean.java, within the listing of your alternative. Here’s the code:

import java.awt.Color;
import java.beans.XMLDecoder;
import javax.swing.JLabel;
import java.io.Serializable;

public class SimpleBean extends JLabel
implements Serializable {
public SimpleBean()
setText( “Hello world!” );
setOpaque( true );
setBackfloor( Color.RED );
setForeground( Color.YELLOW );
setVerticalAlignment( CENTER );
setHorizontalAlignment( CENTER );

}

Question 394. What Is Property Editor In Java Beans?

A property editor is a device for customizing a specific property sort. Property editors are activated within the Properties window. This window determines a property’s sort, searches for a related property editor, and shows the property’s present worth in a related method.

Question 395. What Are The Purpose Of Introspection?

A rising variety of Java object repository websites exist on the Internet in reply to the demand for centralized deployment of applets, lessons, and supply code basically. Any developer who has frolicked looking via these websites for licensable Java code to include right into a program has undoubtedly struggled with problems with find out how to rapidly and cleanly combine code from one explicit supply into an utility.

The method by which introspection is applied offers nice benefits, together with:
► Portability – Everything is completed within the Java platform, so you may write elements as soon as, reuse them in every single place. There aren’t any additional specification information that must be maintained independently out of your part code. There aren’t any platform-specific points to deal with. Your part is just not tied to 1 part mannequin or one proprietary platform. You get all the benefits of the evolving Java APIs, whereas sustaining the portability of your elements.
► Reuse – By following the JavaBeans design conventions, implementing the suitable interfaces, and increasing the suitable lessons, you present yourcomponent with reuse potential that probably exceeds your expectations.

Question 396. What Are Externizable Interface?

Use the Externalizable interface once you want full management over your bean’s serialization (for instance, when writing and studying a particular file format). To use the Externalizable interface that you must implement two strategies: readExternal and writeExternal. Classes that implement Externalizable should have a no-argument constructor.

Question 397. What Is Bean Persistance Property?

A bean has the property of persistence when its properties, fields, and state info are saved to and retrieved from storage. Component fashions present a mechanism for persistence that permits the state of elements to be saved in a non-volatile place for later retrieval.

Question 398. Why Do I Get A Nullpointerexception When Loading A Jar File Into The Beanbox?

Usually that is due to a mistake within the JAR file being loaded. In the meantime, typical errors embrace:

► The MANIFEST file makes use of lessons utilizing the fallacious file separator (“/” needs to be utilized in all platforms).
► The MANIFEST file refers to lessons in a bundle however the precise .class information will not be actually in that bundle.

Question 399. What Are Java Beans?

Java Beans are typical Java lessons which adhere to sure coding conventions:
► Implements java.io.Serializable interface
► Provides no argument constructor
► Provides getter and setter strategies for accessing it is properties.

Question 400. What Are The Different Kinds Of Enterprise Beans?

Stateless session bean- An occasion of those non-persistent EJBs offers a service with out storing an interplay or dialog state between strategies. Any occasion can be utilized for any shopper.

Stateful session bean-An occasion of those non-persistent EJBs maintains state throughout strategies and transactions. Each occasion is related to a specific shopper.

Entity bean-An occasion of those persistent EJBs represents an object view of the information, normally rows in a database. They have a main key as a singular identifier. Entity bean persistence might be both container-managed or bean-managed.

Message-drivenbean- An occasion of those EJBs is built-in with the Java Message Service (JMS) to offer the power for message-driven beans to behave as an ordinary JMS message shopper and carry out asynchronous processing between the server and the JMS message producer.

Question 401. What Are The Methods Of Entity Bean?what Is The Difference Between Container-managed Persistent (cmp) Bean And Bean-managed Persistent(bmp) ?

Container-managed persistence beans are the only for the bean developer to create and probably the most troublesome for the EJB server to assist. This is as a result of all of the logic for synchronizing the bean’s state with the database is dealt with routinely by the container. This signifies that the bean developer would not want to jot down any information entry logic, whereas the EJB server is meant to care for all of the persistence wants routinely. With CMP, the container manages the persistence of the entity bean. A CMP bean developer would not want to fret about JDBC code and transactions, as a result of the Container performs database calls and transaction administration as a substitute of the programmer. Vendor instruments are used to map the entity fields to the database and completely no database entry code is written within the bean class. All desk mapping is specified within the deployment descriptor. Otherwise, a BMP bean developer takes the load of linking an utility and a database on his shoulders.

The bean-managed persistence (BMP) enterprise bean manages synchronizing its state with the database as directed by the container. The bean makes use of a database API to learn and write its fields to the database, however the container tells it when to do every synchronization operation and manages the transactions for the bean routinely. Bean-managed persistence offers the bean developer the flexibleness to carry out persistence operations which might be too sophisticated for the container or to make use of a knowledge supply that isn’t supported by the container.BMP beans will not be 100% database-independent, as a result of they could comprise database-specific code, however CMP beans are unable to carry out sophisticated DML (information manipulation language) statements. EJB 2.Zero specification launched some new methods of querying database (by utilizing the EJB QL – question language).

Question 402. What Is Software Architecture Of Ejb?

Session and Entity EJBs encompass Four and 5 elements respetively:
1. A distant interface (a shopper interacts with it),
2. A house interface (used for creating objects and for declaring business strategies),
3. A bean object (an object, which truly performs business logic and EJB-specific operations).
4. A deployment descriptor (an XML file containing all info required for sustaining the EJB) or a set of deployment descriptors (if you’re utilizing some container-specific options).
5.A Primary Key class – is barely Entity bean particular.

Question 403. Can Entity Beans Have No Create() Methods?

Yes. In some circumstances the information is inserted NOT utilizing Java utility, so it’s possible you’ll solely must retrieve the knowledge, carry out its processing, however not create your personal info of this sort.

Question 404. What Is Bean Managed Transaction?

If a developer would not desire a Container to handle transactions, it is doable to implement all database operations manually by writing the suitable JDBC code. This typically results in productiveness enhance, nevertheless it makes an Entity Bean incompatible with some databases and it enlarges the quantity of code to be written. All transaction administration is explicitly carried out by a developer.

Question 405. What Are Transaction Attributes?

The transaction attribute specifies how the Container should handle transactions for a technique when a shopper invokes the tactic through the enterprise bean’s house or part interface or when the tactic is invoked as the results of the arrival of a JMS message. (Sun’s EJB Specification) Below is an inventory of transactional attributes:

1. NotSupported – transaction context is unspecified.

2. Required – bean’s methodology invocation is made inside a transactional context. If a shopper is just not related to a transaction, a brand new transaction is invoked routinely.

3. Supports – if a transactional context exists, a Container acts just like the transaction attribute is Required, else – like NotSupported.

4. RequiresNew – a technique is invoked in a brand new transaction context.

5. Mandatory – if a transactional context exists, a Container acts just like the transaction attribute is Required, else it throws a javax.ejb.TransactionRequiredException.

6. Never – a technique executes provided that no transaction context is specified.

Question 406. What Are Transaction Isolation Levels In Ejb?

1. Transaction_read_uncommitted- Allows a technique to learn uncommitted information from a DB(quick however not sensible).
2. Transaction_read_committed- Guarantees that the information you might be getting has been dedicated.
3. Transaction_repeatable_read – Guarantees that each one reads of the database would be the similar throughout the transaction (good for learn and replace operations).
4. Transaction_serializable- All the transactions for useful resource are carried out serial.

Question 407. How Ejb Invocation Happens?

Retrieve Home Object reference from Naming Service through JNDI.
Return Home Object reference to the shopper.
Create a brand new EJB Object via Home Object interface.
Create EJB Object from the Ejb Object
Return EJB Object reference to the shopper.
Invoke business methodology utilizing EJB Object reference.
Delegate request to Bean (Enterprise Bean).

Question 408. Is It Possible To Share An Httpsession Between A Jsp And Ejb? What Happens When I Change A Value In The Httpsession From Inside An Ejb?

You can go the HttpSession as parameter to an EJB methodology, provided that all objects in session are serializable.This needs to be take into account as passed-by-value”, that signifies that its read-only within the EJB. If something is altered from contained in the EJB, it wont be mirrored again to the HttpSession of the Servlet Container.The pass-by-reference can be utilized between EJBs Remote Interfaces, as they’re distant references. While it IS doable to go an HttpSession as a parameter to an EJB object, it’s thought-about to be unhealthy observe by way of object oriented design. This is since you are creating an pointless coupling between back-end objects (ejbs) and front-end objects (HttpSession). Create a higher-level of abstraction in your ejbs api. Rather than passing the entire, fats, HttpSession (which carries with it a bunch of http semantics), create a category that acts as a worth object (or construction) that holds all the information that you must go forwards and backwards between front-end/back-end. Consider the case the place your ejb must assist a non-http-based shopper. This increased stage of abstraction can be versatile sufficient to assist it.

Question 409. The Ejb Container Implements The Ejbhome And Ejbobject Classes. For Every Request From A Unique Client, Does The Container Create A Separate Instance Of The Generated Ejbhome And Ejbobject Classes?

The EJB container maintains an occasion pool. The container makes use of these situations for the EJB Home reference regardless of the shopper request. whereas refering the EJB Object lessons the container creates a separate occasion for every shopper request. The occasion pool maintainence is as much as the implementation of the container. If the container offers one, it’s accessible in any other case it isn’t necessary for the supplier to implement it. Having mentioned that, sure many of the container suppliers implement the pooling performance to extend the efficiency of the appliance server. The method it’s applied is once more as much as the implementer.

Question 410. Can The Primary Key In The Entity Bean Be A Java Primitive Type Such As Int?

The main key cannot be a primitive type–use the primitive wrapper lessons, as a substitute. For instance, you should use java.lang.Integer as the first key class, however not int (it needs to be a category, not a primitive)

Question 411. Can You Control When Passivation Occurs?

The developer, in line with the specification, can’t immediately management when passivation happens. Although for Stateful Session Beans, the container can’t passivate an occasion that’s inside a transaction. So utilizing transactions is usually a a technique to manage passivation.

The ejbPassivate() methodology is known as throughout passivation, so the developer has management over what to do throughout this train and might implement the require optimized logic.

Some EJB containers, resembling BEA WebLogic, present the power to tune the container to attenuate passivation calls.

Taken from the WebLogic 6.Zero DTD -“The passivation-strategy might be both “default” or “transaction”. With the default setting the container will try and preserve a working set of beans within the cache. With the “transaction” setting, the container will passivate the bean after each transaction (or methodology name for a non-transactional invocation).

Question 412. What Is The Advantage Of Using Entity Bean For Database Operations, Over Directly Using Jdbc Api To Do Database Operations? When Would I Use One Over The Other?

Entity Beans truly represents the information in a database. It is just not that Entity Beans replaces JDBC API. There are two sorts of Entity Beans Container Managed and Bean Mananged. In Container Managed Entity Bean – Whenever the occasion of the bean is created the container routinely retrieves the information from the DB/Persistance storage and assigns to the article variables in bean for consumer to govern or use them. For this the developer must map the fields within the database to the variables in deployment descriptor information (which varies for every vendor).

In the Bean Managed Entity Bean – The developer has to particularly make connection, retrive values, assign them to the objects within the ejbLoad() which can be known as by the container when it instatiates a bean object. Similarly within the ejbStore() the container saves the article values again the the persistance storage. ejbLoad and ejbStore are callback strategies and might be solely invoked by the container. Apart from this, once you use Entity beans you dont want to fret about database transaction dealing with, database connection pooling and so on. that are taken care by the ejb container. But in case of JDBC it’s important to explicitly do the above options. what suresh advised is precisely excellent. ofcourse, this comes beneath the database transations, however i wish to add this. the beauty of the entity beans of container managed, each time the connection is failed throughout the transaction processing, the database consistancy is mantained routinely. the container writes the information saved at persistant storage of the entity beans to the database once more to offer the database consistancy. the place as in jdbc api, we, builders has to do manually.

Question 413. What Is Ejb Ql?

EJB QL is a Query Language supplied for navigation throughout a community of enterprise beans and dependent objects outlined via container managed persistence. EJB QL is launched within the EJB 2.Zero specification. The EJB QL question language defines finder strategies for entity beans with container managed persistenceand is moveable throughout containers and persistence managers. EJB QL is used for queries of two sorts of finder strategies: Finder strategies which might be outlined within the house interface of an entity bean and which return entity objects. Select strategies, which aren’t uncovered to the shopper, however that are utilized by the Bean Provider to pick persistent values which might be maintained by the Persistence Manager or to pick entity objects which might be associated to the entity bean on which the question is outlined.

Question 414. Brief Description About Local Interfaces?

EEJB was initially designed round distant invocation utilizing the Java Remote Method Invocation (RMI) mechanism, and later prolonged to assist to plain CORBA transport for these calls utilizing RMI/IIOP. This design allowed for max flexibility in growing functions with out consideration for the deployment state of affairs, and was a powerful characteristic in assist of a purpose of part reuse in J2EE.

Many builders are utilizing EJBs domestically — that’s, some or all of their EJB calls are between beans in a single container.

With this suggestions in thoughts, the EJB 2.Zero skilled group has created a neighborhood interface mechanism. The native interface could also be outlined for a bean throughout growth, to permit streamlined calls to the bean if a caller is in the identical container. This doesn’t contain the overhead concerned with RMI like marshalling and so on. This facility will thus enhance the efficiency of functions by which co-location is deliberate.

Local interfaces additionally present the muse for container-managed relationships amongst entity beans with container-managed persistence.

Question 415. What Are The Special Design Care That Must Be Taken When You Work With Local Interfaces?

EIt is vital to know that the calling semantics of native interfaces are totally different from these of distant interfaces. For instance, distant interfaces go parameters utilizing call-by-value semantics, whereas native interfaces use call-by-reference.

This signifies that with a purpose to use native interfaces safely, utility builders must rigorously take into account potential deployment situations up entrance, then determine which interfaces might be native and which distant, and at last, develop the appliance code with these decisions in thoughts.

While EJB 2.Zero native interfaces are extraordinarily helpful in some conditions, the long-term prices of those decisions, particularly when altering necessities and part reuse are taken under consideration, must be factored into the design determination.

Question 416. What Happens If Remove( ) Is Never Invoked On A Session Bean?

In case of a stateless session bean it might not matter if we name or not as in each circumstances nothing is completed. The variety of beans in cache is managed by the container.

In case of stateful session bean, the bean could also be saved in cache until both the session occasions out, by which case the bean is eliminated or when there’s a requirement for reminiscence by which case the information is cached and the bean is distributed to free pool.

Question 417. How Can I Call One Ejb From Inside Of Another Ejb?

EJBs might be shoppers of different EJBs. It simply works. Use JNDI to find the Home Interface of the opposite bean, then purchase an occasion reference, and so forth.

Question 418. What Is An Ejb Context?

EJBContext is an interface that’s applied by the container, and it’s also part of the bean-container contract. Entity beans use a subclass of EJBContext known as EntityContext. Session beans use a subclass known as SessionContext. These EJBContext objects present the bean class with details about its container, the shopper utilizing the bean and the bean itself. They additionally present different capabilities. See the API docs and the spec for extra particulars.

Question 419. What Are The Two Important Tcp Socket Classes?

Socket and ServerSocket.
ServerSocket is used for regular two-way socket communication.
Socket class permits us to learn and write via the sockets. getInputStream() and getOutputStream() are the 2 strategies accessible in Socket class.

Question 420. What Technologies Are Included In J2ee?

The fundamental applied sciences in J2EE are: Enterprise JavaBeansTM (EJBsTM), JavaServer PagesTM (JSPsTM), Java Servlets, the Java Naming and Directory InterfaceTM (JNDITM), the Java Transaction API (JTA), CORBA, and the JDBCTM information entry API.

Question 421. What Is The Difference Between Ejb And Java Beans?

EJB is a specification for J2EE server, not a product; Java beans could also be a graphical part in IDE.

Question 422. What Is Ejb Role In J2ee?

EJB expertise is the core of J2EE. It permits builders to jot down reusable and moveable server-side business logic for the J2EE platform.

Question 423. Tell Me Something About Local Interfaces.

EJB was initially designed round distant invocation utilizing the Java Remote Method Invocation (RMI) mechanism, and later prolonged to assist to plain CORBA transport for these calls utilizing RMI/IIOP. This design allowed for max flexibility in growing functions with out consideration for the deployment state of affairs, and was a powerful characteristic in assist of a purpose of part reuse in J2EE. Many builders are utilizing EJBs domestically, that’s, some or all of their EJB calls are between beans in a single container. With this suggestions in thoughts, the EJB 2.Zero skilled group has created a neighborhood interface mechanism. The native interface could also be outlined for a bean throughout growth, to permit streamlined calls to the bean if a caller is in the identical container. This doesn’t contain the overhead concerned with RMI like marshalling and so on. This facility will thus enhance the efficiency of functions by which co-location is deliberate. Local interfaces additionally present the muse for container-managed relationships amongst entity beans with container-managed persistence.

Question 424. What Is Enterprise Javabeans (ejb) Container?

It manages the execution of enterprise beans for J2EE functions. Enterprise beans and their container run on the J2EE server.

Question 425. What Is In-memory Replication?

The course of by which the contents within the reminiscence of 1 bodily m/c are replicated in all of the m/c within the cluster is known as in-memory replication.

Question 426. What Is Ripple Effect?

The means of propagating the modifications within the properties of a server group throughout runtime to all of the related clones is known as Ripple Effect.

Question 427. What Is A Clone?

The copies of a server group are known as Clones. But not like a Server Group Clones are related to a node and are actual server course of working in that node.

Question 428. What Are The Types Of Scaling?

There are two sorts of scaling: Vertical Scaling and Horizontal Scaling.

Vertical Scaling – When a number of server clones of an utility server are outlined on the identical bodily m/c, it’s known as Vertical Scaling. The goal is to make use of the processing energy of that m/c extra effectively.

Horizontal Scaling – When Clones of an utility server are outlined on a number of bodily m/c, it’s known as Horizontal Scaling. The goal is to make use of a couple of much less highly effective m/c extra effectively.

Question 429. What Is A Server Group?

A server group is a template of an Application Server(and its contents) i.e, it’s a logical illustration of the appliance server. It has the identical construction and attributes as the true Application Server, however it isn’t related to any node, and doesn’t correspond to any actual server course of working on any node.

Question 430. What Is The New Basic Requirement For A Cmp Entity Bean Class In 2.0 From That Of Ejb 1.1?

It have to be summary class. The container extends it and implements strategies that are required for managing the relationships.

Question 431. What’s New In The Ejb 2.0 Specification?

Following are a few of the fundamental options supported in EJB 2.0:
1. Integration of EJB with JMS,
2. Message Driven Beans,
3. Implement further Business strategies in Home interface which aren’t particular for bean occasion, EJB QL.

Question 432. How Can I Access Ejb From Asp?

We can use the Java 2 Platform, Enterprise Edition Client Access Services (J2EETM CAS) COM Bridge 1.0, at present downloadable from Sun.

Question 433. What Is The Relationship Between Local Interfaces And Container-managed Relationships?

Entity beans which have container-managed relationships with different entity beans, have to be accessed in the identical native scope as these associated beans, and subsequently sometimes present a neighborhood shopper view. In order to be the goal of a container-managed relationship, an entity bean with container-managed persistence should present a neighborhood interface.

Question 434. What Is Ejbdoclet?

EJBDoclet is an open supply JavaDoc doclet that generates numerous the EJB associated supply information from customized JavaDoc feedback tags embedded within the EJB supply file.

Question 435. What Is The Difference Between Session And Entity Beans?

An entity bean represents persistent world information from the database; a session bean represents transient user-specific information that may die when the consumer disconnects (ends his session). Generally, the session beans implement business strategies (e.g. Bank.transferFunds) that decision entity beans (e.g. Account.deposit, Account.withdraw)

Question 436. Is It Legal To Have Static Initializer Blocks In Ejb?

Although technically it’s authorized, static initializer blocks are used to execute some piece of code earlier than executing any constructor or methodology whereas instantiating a category. Static initializer blocks are additionally sometimes used to initialize static fields – which can be unlawful in EJB if they’re learn/write – In EJB this may be achieved by together with the code in both the ejbCreate(), setSessionContext() or setEntityContext() strategies.

Question 437. What Are Local Interfaces? Describe.

EJB was initially designed round distant invocation utilizing the Java Remote Method Invocation (RMI) mechanism, and later prolonged to assist to plain CORBA transport for these calls utilizing RMI/IIOP. This design allowed for max flexibility in growing functions with out consideration for the deployment state of affairs, and was a powerful characteristic in assist of a purpose of part reuse in J2EE. Many builders are utilizing EJBs domestically, that’s, some or all of their EJB calls are between beans in a single container. With this suggestions in thoughts, the EJB 2.Zero skilled group has created a neighborhood interface mechanism. The native interface could also be outlined for a bean throughout growth, to permit streamlined calls to the bean if a caller is in the identical container. This doesn’t contain the overhead concerned with RMI like marshalling and so on. This facility will thus enhance the efficiency of functions by which co-location is deliberate. Local interfaces additionally present the muse for container-managed relationships amongst entity beans with container-managed persistence.

Question 438. What Is Difference Between Ejb 1.1 And Ejb 2.0?

The bulk of the modifications in EJB 2.Zero are discovered within the definition of a brand new CMP part mannequin. It’s radically totally different from the outdated CMP mannequin as a result of it introduces a wholly new participant, the persistence supervisor, and a totally new method of defining container-managed fields, in addition to relationships with different beans and dependent objects.

Question 439. What Is The Difference Between Ejbcreate() And Ejbpostcreate?

The objective of ejbPostCreate() is to carry out clean-up database operations after SQL INSERTs (which happen when ejbCreate() is known as) when working with CMP entity beans. ejbCreate() is known as earlier than database INSERT operations. You want to make use of ejbPostCreate() to outline operations, like set a flag, after INSERT completes efficiently.

Question 440. Can I Map More Than One Table In A Cmp?

No, you can’t map a couple of desk to a single CMP Entity Bean. CMP has been, in reality, designed to map a single desk.

Question 441. Is Decorator An Ejb Design Pattern?

No. Decorator design sample, is the one which reveals very low stage runtime polymorphism, for the particular and single object (Instance of the category), however not for atleast for a category. It is the stuff so as to add particular performance to a single & pointed object and leaves others prefer it unmodified. It is having shut similarities like aspectJ stuff, however not with EJB stuff.

Question 442. What Is The Difference Between Ear, Jar And War File?

J2EE defines three sorts of archives:
1. Java Archives (JAR) A JAR file encapsulates a number of Java lessons, a manifest, and a descriptor. JAR information are the bottom stage of archive. JAR information are utilized in J2EE for packaging EJBs and client-side Java Applications.
2. Web Archives (WAR) WAR information are just like JAR information, besides that they’re particularly for internet functions constituted of Servlets, JSPs, and supporting lessons.
3. Enterprise Archives (EAR) ”An EAR file accommodates all the elements that make up a specific J2EE utility.

Question 443. What Is Re-entrant. Is Session Beans Reentrant. Is Entity Beans Reentrant?

If we outline the entity bean as being reentrant, a number of shoppers can hook up with the Entity bean & execute strategies throughout the entity bean concurrently. Container takes care of synchronization. If we outline the entity bean as non-reentrant and many purchasers hook up with it concurrently to execute a technique, exception is thrown .

Question 444. How Many Ejb Objects Are Created For A Bean?

For a Session bean – one EJB object for one bean occasion.
For entity bean – it relies upon , if 2 customers are accessing one row at time then one EJB object is used for each the beans different sensible for every bean one EJB object.

Question 445. What Is Deployment Descriptor?

Deployment descriptor is a XML file. which is used to find the online utility by container.it contains the small print of respective bean.

Question 446. What Are The Call Back Methods In Entity Bean?

setEntityContext().
ejbCreate().
ejbPostCreate().
ejbActivate().
ejbPassivate().
ejbRemove().

Question 447. What Is Local Interface. How Values Will Be Passed?

An EJB can use native shopper view solely whether it is actually assured that different enterprise beans or shoppers will solely handle the bean inside a single JVM. With native shopper view, you are able to do pass-by-reference, which suggests your bean, in addition to the shopper, will work immediately with one copy of the information. Any modifications made by the bean can be seen by the shopper and vice versa. Pass-by-reference eliminates time/system bills for copying information variables, which offers a efficiency benefit.

Question 448. What Is Abstract Schema?

Abstract schema is a part of an entity bean’s deployment descriptor which defines the bean’s persistent fields and their relationship. Abstract schema is specified for entity beans with container managed persistence. We specify the title of the Abstract schema title within the deployment descriptor. The queries written in EJB QL for the finder strategies references this title. The info supplied on this Abstract Schema is utilized by the container for persistence administration and relationship administration.

Question 449. What Is The Difference Between Find And Select Methods In Ejb?

A choose methodology can return a persistent area (or a set thereof) of a associated entity bean. A finder methodology can return solely a neighborhood or distant interface (or a set of interfaces).

Because it’s not uncovered in any of the native or distant interfaces, a choose methodology can’t be invoked by a shopper. It will be invoked solely by the strategies applied throughout the entity bean class. A choose methodology is normally invoked by both a business or a house methodology.

A choose methodology is outlined within the entity bean class. For bean-managed persistence, a finder methodology is outlined within the entity bean class, however for container-managed persistence it’s not.

Question 450. How Does A Servlet Communicate With A Jsp Page?

The following code snippet exhibits how a servlet instantiates a bean and initializes it with FORM knowledge posted by a browser. The bean is then positioned into the request, and the decision is then forwarded to the JSP web page, Bean1.jsp, via a request dispatcher for downstream processing.

Question 451. Are Enterprise Beans Allowed To Use Thread.sleep()?

Enterprise beans make use of the providers offered by the EJB container, similar to life-cycle administration. To keep away from conflicts with these providers, enterprise beans are restricted from performing sure operations: Managing or synchronizing threads.

Question 452. Is It Possible To Specify Multiple Jndi Names When Deploying An Ejb?

No. To obtain this you must deploy your EJB a number of occasions every specifying a special JNDI identify.

Question 453. 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 actually potential. In truth, there’s an instance that ships with the Inprise Application Server of an Account interface with separate implementations for CheckingAccount and Financial savingsAccount, considered one of which was CMP and considered one of which was BMP.

Question 454. Can An Ejb Send Asynchronous Notifications To Its Clients?

Asynchronous notification is a identified gap within the first variations of the EJB spec. The beneficial answer to that is to make use of JMS, which is changing into out there in J2EE-compliant servers. The different possibility, after all, is to make use of client-side threads and polling. This isn’t a really perfect answer, but it surely’s workable for a lot of eventualities.

Question 455. Is There A Guarantee Of Uniqueness For Entity Beans?

There is not any such assure. The server (or servers) can instantiate as many cases of the identical underlying Entity Bean (with the identical PK) because it needs. However, every occasion is assured to have up-to-date knowledge values, and be transactionally constant, so uniqueness isn’t required. This permits the server to scale the system to help a number of threads, a number of concurrent requests, and a number of hosts.

Question 456. Can A Class Be It’s Own Event Handler? Explain How To Implement This.

Sure. an instance may very well be a category that extends Jbutton and implements MotionListener. In the actionPerformed methodology, put the code to carry out when the button is pressed.

Question 457. Why Does Jcomponent Have Add() And Remove() Methods But Component Does Not?

Because JComponent is a subclass of Container, and might comprise different parts and jcomponents.

Question 458. How Would You Create A Button With Rounded Edges?

There’s 2 methods. The very first thing is to know {that a} JButton’s edges are drawn by a Border. so you may override the Button’s paintComponent(Graphics) methodology and draw a circle or rounded rectangle (no matter), and switch off the border. Or you may create a customized border that pulls a circle or rounded rectangle round any element and set the button’s border to it.

Question 459. If I Wanted To Use A Solarisui For Just A Jtabbedpane, And The Metal Ui For Everything Else, How Would I Do That?

In the UIDefaults desk, override the entry for tabbed pane and put within the SolarisUI delegate. (I don’t realize it offhand, however I believe it’s “com.solar.ui.motiflookandfeel.MotifTabbedPaneUI” – something simiar is an effective reply.)

Question 460. What Is The Difference Between The ‘font’ And ‘fontmetrics’ Class?

The Font Class is used to render ‘glyphs’ – the characters you see on the display screen. FontMetrics encapsulates details about a selected font on a selected Graphics object. (width of the characters, ascent, descent)

Question 461. What Class Is At The Top Of The Awt Event Hierarchy?

The java.awt.AWTEvent class is the highest-level class within the AWT event-class hierarchy..

Question 462. Explain How To Render An Html Page Using Only Swing.

Use a JEditorPane or JTextPane and set it with an HTMLEditorKit, then load the textual content into the pane.

Question 463. How Would You Detect A Keypress In A Jcombobox?

This is a trick. most individuals would say ‘add a KeyListener to the JComboBox’ – however the suitable reply is ‘add a KeyListener to the JComboBox’s editor element.’

Question 464. Why Should The Implementation Of Any Swing Callback (like A Listener) Execute Quickly?

Because callbacks are invoked by the occasion dispatch thread which might be blocked processing different occasions for so long as your methodology takes to execute.

Question 465. In What Context Should The Value Of Swing Components Be Updated Directly?

Swing parts needs to be up to date immediately solely within the context of callback strategies invoked from the occasion dispatch thread. Any different context isn’t thread secure.

Question 466. Why Would You Use Swingutilities.invokeandwait Or Swingutilities.invokelater?

I need to replace a Swing element however I’m not in a callback. If I need the replace to occur instantly (maybe for a progress bar element) then I’d use invokeAndWait. If I don’t care when the replace happens, I’d use invokeLater.

Question 467. If Your Ui Seems To Freeze Periodically, What Might Be A Likely Reason?

A callback implementation like MotionListener.actionPerformed or MouseListener.mouseClicked is taking a very long time to execute thereby blocking the occasion dispatch thread from processing different UI occasions.

Question 468. Which Swing Methods Are Thread-safe?

The solely thread-safe strategies are repaint(), revalidate(), and invalidate()

Question 469. Why Won’t The Jvm Terminate When I Close All The Application Windows?

The AWT occasion dispatcher thread isn’t a daemon thread. You should explicitly name System.exit to terminate the JVM.

Question 470. Which Method Is Used For Setting Security In Applets?

setSecuritySupervisor() methodology is used for setting safety in applets.

Question 471. What Is Jms?

JMS is an acronym used for Java Messaging Service. It is Java’s reply to creating software program utilizing asynchronous messaging. It is likely one of the official specs of the J2EE applied sciences and is a key know-how.

Question 472. How Jms Is Different From Rpc?

In RPC the strategy invoker waits for the strategy to complete execution and return the management again to the invoker. Thus it’s fully synchronous in nature. While in JMS the message sender simply sends the message to the vacation spot and continues it is personal processing. The sender doesn’t look forward to the receiver to reply. This is asynchronous habits.

Question 473. What Are The Advantages Of Jms?

JMS is asynchronous in nature. Thus not all of the items must be up on a regular basis for the applying to operate as an entire. Even if the receiver is down the MOM will retailer the messages on it is behalf and can ship them as soon as it comes again up. Thus not less than part of software can nonetheless operate as there is no such thing as a blocking.

Question 474. Are You Aware Of Any Major Jms Products Available In The Market?

IBM’s MQ Series is likely one of the hottest product used as Message Oriented Middleware. Some of the opposite merchandise are SonicMQ, iBus and many others.All the J2EE compliant software servers come constructed with thier personal implementation of JMS.

Question 475. What Are The Different Types Of Messages Available In The Jms Api?

Message, TextMessage, BytesMessage, StreamMessage, ObjectMessage, MapMessage are the completely different messages out there within the JMS API.

Question 476. What Are The Different Messaging Paradigms Jms Supports?

Publish and Subscribe i.e. pub/suc and Point to Point i.e. p2p.

Question 477. What Is The Difference Between Topic And Queue?

A subject is usually used for one to many messaging i.e. it helps publish subscribe mannequin of messaging. While queue is used for one-to-one messaging i.e. it helps Point to Point Messaging.

Question 478. What Is The Role Of Jms In Enterprise Solution Development?

JMS is usually used within the following eventualities
1. Enterprise Application Integration: – Where a legacy software is built-in with a brand new software through messaging.
2. B2B or Business to Business: – Businesses can work together with one another through messaging as a result of JMS permits organizations to cooperate with out tightly coupling their business methods.
3. Geographically dispersed models: – JMS can guarantee secure trade of knowledge amongst the geographically dispersed models of a company.
4. One to many purposes: – The purposes that must push knowledge in packet to very large variety of purchasers in a one-to-many trend are good candidates for the use JMS. Typical such purposes are Auction Sites, Stock Quote Services and many others.

Question 479. What Is The Use Of Message Object?

Message is a lightweight weight message having solely header and properties and no payload. Thus if the receivers are to be notified about an occasion, and no knowledge must be exchanged then utilizing Message will be very environment friendly.

Question 480. What Is The Basic Difference Between Publish Subscribe Model And P2p Model?

Publish Subscribe mannequin is usually utilized in one-to-many scenario. It is unreliable however very quick. P2P mannequin is utilized in one-to-one scenario. It is very dependable.

Question 481. What Is The Use Of Bytesmessage?

BytesMessage accommodates an array of primitive bytes in it is payload. Thus it may be used for switch of knowledge between two purposes of their native format which will not be suitable with different Message varieties. It can be helpful the place JMS is used purely as a transport between two methods and the message payload is opaque to the JMS shopper. Whenever you retailer any primitive sort, it’s transformed into it is byte illustration after which saved within the payload. There is not any boundary line between the completely different knowledge varieties saved. Thus you may even learn a protracted as quick. This would end in inaccurate knowledge and therefore it’s advisable that the payload be learn in the identical order and utilizing the identical sort through which it was created by the sender.

Question 482. What Is The Use Of Streammessage?

StreamMessage carries a stream of Java primitive varieties because it’s payload. It accommodates some conveient strategies for studying the information saved within the payload. However, StreamMessage prevents studying a protracted worth as quick, one thing that’s allowed in case of BytesMessage. This is so as a result of the StreamMessage additionally writes the kind info together with the worth of the primitive sort and enforces a set of strict conversion guidelines which really prevents studying of 1 primitive sort as one other.

Question 483. What Is The Use Of Textmessage?

TextMessage accommodates occasion of java.lang.String because it’s payload. Thus it is vitally helpful for exchanging textual knowledge. It can be used for exchanging advanced character knowledge similar to an XML doc.

Question 484. What Is The Use Of Objectmessage?

ObjectMessage accommodates a Serializable java object because it’s payload. Thus it permits trade of Java objects between purposes. This in itself mandates that each the purposes be Java purposes. The shopper of the message should typecast the thing acquired to it is applicable sort. Thus the buyer ought to earlier than hand know the precise sort of the thing despatched by the sender. Wrong sort casting would end in ClassCastException. Moreover the category definition of the thing set within the payload needs to be out there on each the machine, the sender in addition to the buyer. If the category definition isn’t out there within the shopper machine, an try and sort solid would end in ClassNotFoundException. Some of the MOMs would possibly help dynamic loading of the specified class over the community, however the JMS specification doesn’t mandate this habits and can be a price added service if offered by your vendor. And counting on any such vendor particular performance would hamper the portability of your software. Most of the time the category must be put within the classpath of each, the sender and the buyer, manually by the developer.

Question 485. What Is The Use Of Mapmessage?

A MapMessage carries name-value pair because it’s payload. Thus it is payload is just like the java.util.Properties object of Java. The values will be Java primitives or their wrappers.

Question 486. What Is The Difference Between Bytesmessage And Streammessage??

BytesMessage shops the primitive knowledge varieties by changing them to their byte illustration. Thus the message is one contiguous stream of bytes. While the StreamMessage maintains a boundary between the completely different knowledge varieties saved as a result of it additionally shops the kind info together with the worth of the primitive being saved. BytesMessage permits knowledge to be learn utilizing any sort. Thus even when your payload accommodates a protracted worth, you may invoke a technique to learn a brief and it’ll return you one thing. It won’t provide you with a semantically appropriate knowledge however the name will achieve studying the primary two bytes of knowledge. This is strictly prohibited within the StreamMessage. It maintains the kind info of the information being saved and enforces strict conversion guidelines on the information being learn.

Question 487. What Is Point-to-point Messaging?

With point-to-point message passing the sending software/shopper establishes a named message queue within the JMS dealer/server and sends messages to this queue. The receiving shopper registers with the dealer to obtain messages posted to this queue. There is a one-to-one relationship between the sending and receiving purchasers.

Question 488. What Is The Advantage Of Persistent Message Delivery Compared To Nonpersistent Delivery?

If the JMS server experiences a failure, for instance, an influence outage, any message that it’s holding in major storage probably may very well be misplaced. With persistent storage, the JMS server logs each message to secondary storage. (The logging happens on the entrance finish, that’s, as a part of dealing with the ship operation from the message producing shopper.) The logged message is faraway from secondary storage solely after it has been efficiently delivered to all consuming purchasers .

Question 489. Give An Example Of Using The Publish/subscribe Model.

JMS can be utilized to broadcast shutdown messages to purchasers related to the Weblogic server on a module clever foundation. If an software has six modules, every module behaves like a subscriber to a named subject on the server.

Question 490. How Is A Java Object Message Delivered To A Non-java Client?

It is in accordance with the specification that the message despatched needs to be acquired in the identical format. A non-java shopper can not obtain a message within the type of java object. The supplier in between handles the conversion of the information sort and the message is transferred to the opposite finish.

Question 491. What Is Mdb And What Is The Special Feature Of That?

MDB is Message pushed bean, which very a lot resembles the Stateless session bean. The incoming and out going messages will be dealt with by the Message pushed bean. The potential to speak asynchronously is the particular characteristic in regards to the Message pushed bean.

Question 492. What Are The Types Of Messaging?

There are two sorts of Messaging.

Synchronous Messaging: Synchronous messaging includes a shopper that waits for the server to reply to a message.

Asynchronous Messaging: Asynchronous messaging includes a shopper that doesn’t look forward to a message from the server. An occasion is used to set off a message from a server.

Question 493. What Are The Core Jms-related Objects Required For Each Jms-enabled Application?

Each JMS-enabled shopper should set up the next:
• A connection object offered by the JMS server (the message dealer)
• Within a connection, a number of classes, which give a context for message sending and receiving
• Within a session, both a queue or subject object representing the vacation spot (the message staging space) throughout the message dealer
• Within a session, the suitable sender or writer or receiver or subscriber object (relying on whether or not the shopper is a message producer or shopper and makes use of a point-to-point or publish/subscribe technique, respectively) Within a session, a message object (to ship or to obtain)

Question 494. What Is The Use Of Load And Require In Ruby?

A way that hundreds and processes the Ruby code from a separate file, together with no matter courses, modules, strategies, and constants are in that file into the present scope. load is analogous, however moderately than performing the inclusion operation as soon as, it reprocesses the code each time load is named.

Question 495. What Function Converts All Html Special Symbols To Html Entities In Ruby?

This operate ae_some_html converts all HTML particular symbols to HTML entities.

Question 496. What Is The Log That Has To Seen To Check For An Error In Ruby Rails?

Rails will report errors from Apache in log/apache.log and errors from the Ruby code in log/growth.log. If you are having an issue, do take a look at what these logs are saying. On Unix and Mac OS X you could run tail -f log/growth.log in a separate terminal to observe your software’s execution.

Question 497. What Is The Scope Of A Local Variable In Ruby?

A brand new scope for a neighborhood variable is launched within the toplevel, a category (module) definition, a technique defintion. In a process block a brand new scope is launched however you may entry to a neighborhood variable outdoors the block.

The scope in a block is particular as a result of a neighborhood variable needs to be localized in Thread and Proc objects. whereas, till, and for are management buildings and the scope is shared with the skin of those buildings. loop is a technique and the appended block introduces a brand new scope.

Question 498. What Is The Use Of Global Variable $ In Ruby?

If you declare one variable as international we will entry any the place, as class variable.

Question 499. Where Does The Start_tabnav Gets Informations For Tabs Rendering In Ruby Rail?

<%= start_tabnav :fundamental %>
The :fundamental Symbol let the start_tabnav methodology know to search for a particular MainTabnav class the place all of the magic occurs.

Question 500. What Type Messaging Is Provided By Jms?

Both synchronous and asynchronous are offered by JMS.

Question 501. What Are The Different Parts Of A Jms Message ?

A JMS message accommodates three components. a header, an elective properties and an elective physique.

Question 502. What Is The Role Of The Jms Provider?

The JMS supplier handles safety of the messages, knowledge conversion and the shopper triggering. The JMS supplier specifies the extent of encryption and the safety degree of the message, the very best knowledge sort for the non-JMS shopper.

Question 503. What Is The Difference Between Byte Message And Stream Message?

Bytes Message shops knowledge in bytes. Thus the message is one contiguous stream of bytes. While the Stream Message maintains a boundary between the completely different knowledge varieties saved as a result of it additionally shops the kind info together with the worth of the primitive being saved. Bytes Message permits knowledge to be learn utilizing any sort. Thus even when your payload accommodates a protracted worth, you may invoke a technique to learn a brief and it’ll return you one thing. It won’t provide you with a semantically appropriate knowledge however the name will achieve studying the primary two bytes of knowledge. This is strictly prohibited within the Stream Message. It maintains the kind info of the information being saved and enforces strict conversion guidelines on the information being learn.

Question 504. What Is Byte Message ?

Byte Messages accommodates a Stream of uninterrupted bytes. Byte Message accommodates an array of primitive bytes in it is payload. Thus it may be used for switch of knowledge between two purposes of their native format which will not be suitable with different Message varieties. It can be be helpful the place JMS is used purely as a transport between two methods and the message payload is opaque to the JMS shopper.

Question 505. What Is Object Message ?

Object message accommodates a bunch of serializeable java object. So it permits trade of Java objects between purposes. sot each the purposes have to be Java purposes.

Question 506. What Is Text Message?

Text messages accommodates String messages (since being broadly used, a separate messaging Type has been supported) . It is helpful for exchanging textual knowledge and sophisticated character knowledge like XML.

Question 507. What Is Map Message?

map message accommodates identify worth Pairs. The values will be of sort primitives and its wrappers. The identify is a string.

Question 508. What Is Stream Message ?

Stream messages are a bunch of java primitives. It accommodates some handy strategies for studying the information. However Stream Message prevents studying a protracted worth as quick. This is so as a result of the Stream Message additionally writes the kind info together with the worth of the primitive sort and enforces a set of strict conversion guidelines which really prevents studying of 1 primitive sort as one other.

Question 509. What Is The Difference Between Queue And Topic ?

A subject is usually used for one to many messaging , whereas queue is used for one-to-one messaging. Topic .e. it helps publish subscribe mannequin of messaging the place queue helps Point to Point Messaging.

Question 510. What Is Messaging?

Messaging is a mechanism by which knowledge will be handed from one software to a different software.

Question 511. Explain About The Programming Language Ruby?

Ruby is the mind youngster of a Japanese programmer Matz. He created Ruby. It is a cross platform object oriented language. It helps you in figuring out what your code does in your software. With legacy code it provides you the ability of administration and group duties. Being open supply, it did go into nice lengths of growth.

Question 512. Explain About Class Libraries In Ruby?

Ruby has a robust set of sophistication libraries and it covers from a wide range of domains similar to thread programming, domains and knowledge varieties. Also ruby is a brand new language and it additionally has further libraries coming on daily basis. Many of the brand new languages which do exist have large libraries due to their age.

Question 513. Explain About Portability?

Ruby language will be ported to many platforms. Ruby packages will be ported to many platforms with none modification to the supply code. This characteristic made the language very helpful and extremely utilized by many programmers worldwide. Some of the platforms used are DOS, UNIX, WINDOWS, and many others.

Question 514. Explain About Garbage Collection Feature Of Ruby?

Ruby is an object oriented language and each object oriented language tends to allocate many objects throughout execution of this system. Ruby deletes unallocated and unused objects mechanically. This characteristic will be managed by making use of correct syntax and program by ruby.

Question 515. Explain About The Command Line Options?

Ruby`s language is executed from the command line like a lot of the scripting languages. Programming and habits language atmosphere will be managed from the interpreter itself. Some of the instructions that are used are as follows –d, -h, -e prog, -v, -T, -r lib, and many others.

Question 516. Explain About Environment Variables Present In Ruby?

Following are among the atmosphere variables used to manage the habits programming of ruby. While programming ENV object lists among the present variables. RUBYLIB path searches for libraries. Make certain that you simply separate every path with colons. RUBYOPT passes command line choices to Ruby interpreter. There are many extra which will be obtained by looking out the massive pool of library.

Question 517. Explain About Operators In Ruby?

Like all the fashionable languages Ruby helps many various operators to its credit score. Most of the operators in Ruby are the truth is strategies because of the object oriented nature of the language. This characteristic provides Ruby an edge over its rivals. Semantics of those operators will be modified because of the object oriented nature of the language.

Question 518. Explain About The Defined Operator?

Define operator defines whether or not a handed expression is outlined or not. If the expression is outlined it returns the outline string or null if the expression isn’t outlined. If a variable is outlined it will get initialized. If method_call is outlined as true then methodology additionally will get outlined. This can be the identical case with tremendous and yield.

Question 519. Explain About Methods?

Methods in ruby mainly carry out two features, named operation and the code current within the class which does a selected operate. In Ruby all of your algorithms stay in strategies which inturn is current on objects. Ruby doesn’t have any provision for features. Code current in Ruby is at all times a technique of some object. Behind the scenes ruby provides you the pliability to work with strategies as features if you’re contemplating working with different languages.

Question 520. Explain About Normal Method Class?

This operate calls a technique and it may take any variety of arguments and expr. Make certain that you simply put an asterisk or an ampersand earlier than the expression. Last expr argument will be declared with a hash with none braces. If you need to improve the dimensions of the array worth then just be sure you put an asterisk earlier than expression. “::” can be utilized to separate the category from strategies.

Question 521. Explain About Ruby Names?

Classes, variables, strategies, constants and modules will be referred by ruby names. When you need to distinguish between numerous names you may specify that by the primary character of the identify. Some of the names are used as reserve phrases which shouldn’t be used for another goal. A reputation will be lowercase letter, higher case letter, quantity, or an underscore, just be sure you comply with the identify by identify characters.

Question 522. Explain About Variables?

There are 4 several types of variables they’re native, occasion, international, and sophistication. Variables can be utilized in this system with none declaration they usually can comprise knowledge of any sort. An area variable accommodates decrease case characters adopted by identify characters. Instance variable begins with a @ signal adopted by identify characters.

Question 523. Explain About Class Variable And Global Variable?

A category variable begins with an @@ signal which is instantly adopted by higher or decrease case letter. You may put some identify characters after the letters which stand to be a pure elective. A category variable will be shared amongst all of the objects of a category. A single copy of a category variable exists for every given class.
To write a world variable you begin the variable with a $ signal which needs to be adopted by a reputation character. Ruby defines a variety of international variables which additionally embrace different punctuation characters similar to $_ and $-k.

Question 524. How Does Ruby Deal With Extremely Large Numbers?

Unlike different programming languages ruby offers with extraordinarily massive numbers it doesn’t have any obstacles. There is not any restrict on the extent of restrict of quantity utilization. Ruby performs this operate with two completely different courses they’re fixnum and bignum. Fixnum represents simply managed small numbers and bignum represents large numbers. Ruby totally handles the functioning of those two courses which leaves a programmer to focus on his arithmetic operations.

Question 525. Explain About Float, Dig And Max?

Float class is used at any time when the operate adjustments continuously. It acts as a sub class of numeric. They signify actual characters by making use of the native structure of the double precision floating level.
Max is used at any time when there’s a large want of Float.
Dig is used everytime you need to signify a float in decimal digits.

Question 526. Explain About Interpolation?

Interpolation is an important course of in Ruby. Interpolation is the method of inserting a string right into a literal. There is just one means in which you’ll interpolate a string right into a literal by putting a Hash (#) inside {} open and shut brackets. This refers to a brand new identify to by referring to the copy of the unique methodology.

Question 527. Explain About Ruby Code Blocks?

Ruby code blocks kind an necessary a part of ruby and are very enjoyable to make use of. With the assistance of this characteristic you may place your code between do-end and you’ll affiliate them with methodology invocations and you will get an impression that they’re like parameters. They might seem close to to a supply of the code and adjoining to a technique name. The code isn’t executed throughout this system execution however it’s executed when the context of its look is met or when it enters a technique.

Question 528. What Is Jboss?

JBoss is a well-liked open supply software server primarily based on JEE know-how. Being JEE primarily based, the JBoss helps cross-platform java purposes. It was embedded with Apache Tomcat net server. It runs below any JVM of 1.Three or later variations. JBoss helps JNDI, Servlet/JSP (Tomcat or Jetty), EJB, JTS/JTA, JCA, JMS, Clustering (JavaTeams), Web Services (Axis), and IIOP integration (JacORB).

Question 529. What Is Jta?

Java Transaction API is an ordinary between the transaction supervisor and the entities participated within the distributed transaction system. These entities are transaction supervisor, the applying server and transactional purposes. JTA permits the purposes to carry out distributed transactions between a number of methods related to the community. The database entry energy is drastically elevated by supporting JTA in a JDBC driver.

The useful resource supervisor will be considered as a RDBMS. This element handles the precise database administration. The communication channel is the useful resource adapter which is a JDBC driver. For a selected enterprise database, the useful resource supervisor native transaction is carried out for a single transaction.

Question 530. How Can You Start A Jta Transaction From A Servlet Deployed On Jboss ?

JBoss registers within the JNDI tree a JTA UserTransaction Object which will be consumer to handle a distributed transaction.

Question 531. Which Component Handles Cluster Communication In Jboss ?

The JGroups framework offers providers to allow peer-to-peer communications between nodes in a cluster. It is constructed on high a stack of community communication protocols that present transport, discovery, reliability and failure detection, and cluster membership administration providers.

Question 532. Is It Possible To Put A Jboss Server Instance Into Multiple Cluster At The Same Time ?

It is technically potential to place a JBoss server occasion into a number of clusters on the identical time, this follow is mostly not beneficial, because it will increase the administration complexity.

Question 533. What’s Jboss Cache In Short ?

JBossCache allows simple distribution of datasets throughout your computing environments. It relies on JGroups and allows clustering and excessive availability of that knowledge. You might select to distribute the information with JBoss Messaging to maneuver it the place it’s wanted for computation or event-based programming.

Question 534. What Do You Know About Seam ?

Built on the requirements JavaServer Faces and EJB 3.0, JBoss Seam unifies element and programming fashions and delivers a constant and highly effective framework for speedy creation of net purposes with Java EE 5.0. Seam simplifies net software growth and allows new performance that was tough to implement by hand earlier than, similar to stateful conversations, multi-window operation, and dealing with concurrent fine-grained AJAX requests. Seam additionally unifies and integrates fashionable open supply applied sciences like Facelets, Hibernate, iText, and Lucene.

Question 535. Does Seam Run On Other Application Servers Besides Jboss ?

Seam runs superbly on different software servers – similar to the whole lot else the Hibernate workforce does, this isn’t a JBoss-only factor.

Question 536. What’s Jboss Jbpm ?

JBoss jBPM is a platform for course of languages. At the bottom there’s a java library to outline and execute graphs. The precise course of constructs like e.g. ship electronic mail, consumer process and replace database are outlined on high of this. Every course of language is made up of a set of such course of constructs. And that’s what is pluggable on this base library. On high of the JBoss jBPM base library, there are applied a number of course of languages as a set of course of constructs: jPDL, BPEL and SEAM pageflow:

• jPDL is a course of language with a clear interface to Java and really refined process administration capabilities. There is not any commonplace for Java course of languages, so it’s proprietary.
• BPEL is a service orchestration language. As mentioned earlier than, in BPEL, you may write new providers as a operate of different providers. This is usually a element of an Enterprise Service Bus (ESB).
• SEAM pageflow is a language that permits for the graphically outline the navigation between pages in a SEAM net software.

Question 537. Can I Run Seam Outside Of Jboss As?

Yes, you may run Seam purposes in plain Tomcat 5.5+ or within the Sun GlassFish software server. To run Seam software in Tomcat, you want a variety of further library recordsdata and some configuration recordsdata to bootstrap the JBoss EJB3 inside Tomcat. Please consult with the deploy.tomcat ANT construct goal for the Seam reserving instance (in theexamples/reserving listing of the Seam distribution) for extra on construct a Tomcat WAR for Seam purposes. Refer to this blog post on run Seam in Sun’s Glassfish software server.

Question 538. Can I Run Seam In A J2ee Environment?

Yes, as of Seam 1.1, you should utilize Seam in any J2EE software server, with one caveat: you won’t be able to make use of EJB 3.Zero session beans. However, you should utilize both Hibernate or JPA for persistence, and you should utilize Seam JavaBean parts as an alternative of session beans.

Question 539. Can I Run Seam With Jdk 1.4 And Earlier?

No, Seam solely works on JDK 5.Zero and above. It makes use of annotations and different JDK 5.Zero options.

Question 540. Where Can I Find Seam Examples And Documentation?

The supply code and construct script of all Seam instance purposes are included within the examples listing of theSeam distribution. Seam documentation is obtainable right here.

Question 541. Where Can I Ask Questions And Make Suggestions About Seam?

Please use the Seam User’s dialogue discussion board for consumer questions.

Question 542. Are There Books About Seam?

Yes, Prentice Hall’s “JBoss Seam: Simplicity and Power Beyond Java EE 5.0” is a complete information for Seam written by JBoss insiders.

Question 543. Can I Use Ajax With Seam?

Yes, Seam offers wonderful help for AJAX. First, Seam helps the ICEfaces and Ajax4JSF Ajax element libraries for JSF. If you like a extra “quaint” method, Seam offers a whole JavaScript remoting framework which helps you to name Seam parts and subscribe to JMS subjects immediately from the shopper. Please consult with the Seam remoting instance software on use AJAX remoting to implement a chat room.
Finally, Seam’s concurrency mannequin is designed particularly to be used with Ajax.

Question 544. Can I Unit Test Seam Applications Without Starting The Application Server?

Yes, Seam offers its personal integration take a look at framework primarily based on TestNG You can simply mock all Seam providers utilizing these amenities with out ever loading an software server or a database.

Question 545. What’s The Difference Between Hibernate And Ejb 3 ? Don’t You Think Ejb 3 Is Just A Clone Of Hibernate ?

The notion of EJB3 as being a easy clone of Hibernate is based on developer familiarity with Hibernate and a similarity of naming, in addition to widespread goal, and that Hibernate is morphing itself into an EJB3 implementation primarily based on the work going into the specification, not the opposite means round.

EJBs are imagined to be parts, within the sense that they don’t seem to be only one class, however a set of courses, descriptors and utilization and administration contracts. All of this so as to permit a container (JBoss, Weblogic, and many others.) to supply providers to these parts, and to have the ability to reuse and distribute this parts. This providers are, amongst others, transactions, concurrent entry management, safety, occasion pooling, etcetera.

Hibernat is “simply” an ORM (Object/Relational Mapping) device. Quick and soiled, this implies you may retailer an object tree belonging to an class hierarchy in a relational DB with out writing a single SQL question. Quite cool, IMO. But no transaction management, no occasion pooling, no concurrency management, and definitely no safety.

Question 546. Which Hibernate Object Wraps The Jdbc Connection ?

The Session interface wraps a JDBC Connection. This interface is a single threaded object which represents a single unit of labor with software and chronic database. It’s retrieved by the SessionFactory’s open Session() methodology.

Question 547. Ok, Is The Session Factory Thread Safe?

Yes: that’s many threads can entry it cuncurrentely and request for classes. It holds cached knowledge that has been learn in a single unit of labor and could also be reused in a future unit of labor. Good follow is to create it when the applying is initialized.

Question 548. What If You Need To Span Your Transaction Across Multiple Servlet Invocations ?

You cannot with a Servlet. A JTA transaction should begin and end inside a single invocation (of the service() methodology). You ought to think about using a Stateful SB. In a SFSB with a JTA transaction, the affiliation between the bean occasion and the transaction is retained throughout a number of shopper calls.

Question 549. What Are The Differences Between Ejb 3.0 And Ejb 2.0 ?

EJBs are actually plain previous Java objects (POJO) that expose common business interfaces (POJI), and there’s no requirement for residence interfaces.

Use of metadata annotations, an extensible, metadata-driven, attribute-oriented framework that’s used to generate Java code or XML deployment descriptors.
Removal of the requirement for particular interfaces and deployment descriptors (deployment descriptor info will be changed by annotations).
Interceptor facility to invoke consumer strategies on the invocation of business strategies or at life cycle occasions.
Default values are used at any time when potential (“configuration by exception” method).
Reduction within the necessities for utilization of checked exception.
An entire new persistence mannequin (primarily based on the JPA commonplace), that supersedes EJB 2.x entity beans.
Question 550. What Is The Diffrence Between A Local-tx-datasource And A Xa-datasource? Can You Use Transactions In Both ?

An area-tx-datasource identifies an information supply that makes use of transactions, even distributed trans actions throughout the native software server, however doesn’t use distributed transactions amongst a number of software servers. An xa-datasource then again identifies an information supply that makes use of distributed transaction amongst multi-ple software servers.

Question 551. What Do You Need To Set-up A Cluster With Jboss ?

Basically beginning JBoss with the “all” configuration accommodates the whole lot wanted for clustering: It has all of the libraries for clustering:
• JGroups.jar, jboss-cache.jar
• Clustered beans (cluster-service.xml)
• HA-JNDI
• HTTP session replications (tc5-cluster-service.xml)
• Farming
• HA-JMS.

Question 552. What Optimization Could I Use If The Ejb Container Is The Only Point Of Write Access To The Database ?

You might activate the “Commit Option A” that’s the container caches entity bean state between transactions. This possibility assumesthat the container has unique entry to the persistentstore and due to this fact it doesn’t must synchronizethe in-memory bean state from the persistent retailer originally of every transaction.

Question 553. Explain The Difference Between Nil And False In Ruby?

False is a boolean datatype
Nil isn’t an information sort

Question 554. Explain The Use Of Global Variable $ In Ruby?

If you declare one variable as international we will entry any the place, the place as class variable visibility solely within the class.

Question 555. What Is The Use Of Super In Ruby Rails?

► Ruby makes use of the tremendous key phrase to name the superclass implementation of the present methodology.
► Within the physique of a technique, calls to tremendous acts similar to a name to that authentic methodology.
► The seek for a technique physique begins within the superclass of the article that was discovered to include the unique methodology.
def url=(addr)
tremendous (addr.clean? || addr.starts_with?(‘http’)) ? addr : http://#{addr}
finish

Question 556. Interpolation Is A Very Important Process In Ruby, Comment?

► Interpolation is the method of inserting a string right into a literal.
► You can interpolate a string right into a literal by putting a Hash (#) inside {} open and shut brackets.
► This refers to a brand new identify to by referring to the copy of the unique methodology.

Question 557. Describe The Environment Variables Present In Ruby.

RUBYOPT
Additional command-line choices to Ruby; examined after actual command-line choices are parsed ($SAFE should be 0).

RUBYLIB
Additional search path for Ruby applications ($SAFE should be 0).

RUBYPATH
With -S possibility, search path for Ruby applications (defaults to PATH).

RUBYSHELL
Shell to make use of when spawning a course of; if not set, will even examine SHELL or COMSPEC. DLN_LIBRARY_PATH Search path for dynamically loaded modules.

RUBYLIB_PREFIX
(Windows solely) Mangle the RUBYLIB search path by including this prefix to every part.

Question 558. Explain The Concepts And Capabilities Of Garbage Collection Feature Of Ruby?

► Ruby is an object oriented language and each object oriented language tends to allocate many objects throughout execution of this system.
► Ruby deletes unallocated and unused objects routinely.
► This characteristic could be managed by making use of correct syntax and program by way of ruby.

Question 559. Describe Class Libraries In Ruby?

► The Ruby customary library extends the inspiration of the Ruby built-in library with lessons and abstractions for a wide range of programming wants, together with community programming, working system providers, threads, and extra.
► These lessons present versatile capabilities at a excessive degree of abstraction, supplying you with the flexibility to create highly effective Ruby scripts helpful in a wide range of downside domains.

Question 560. What Is Rails?

► Ruby on Rails is an open supply internet utility framework for the Ruby programming language.
► It is used with an Agile growth methodology that’s utilized by internet builders for fast growth.

Question 561. Why Ruby On Rails?

There are lot of benefits of utilizing ruby on rails
1. DRY Principal
2. Convention over Configuration
3. Gems and Plugins
4. Scaffolding
5. Pure OOP Concept
6. Rest Support
7. Rack help
8. Action Mailer
9. Rpc help
10. Rexml Support and many others..

Question 562. How May Messaging Models Do Jms Provide For And What Are They?

JMS present for 2 messaging fashions, publish-and subscribe and point-to-point queuing.

Question 563. Are We Allowed To Change The Transaction Isolation Property In Middle Of A Transaction?

No. You can not change the transaction isolation degree in the midst of transaction.

Question 564. Should Synchronization Primitives Be Used On Bean Methods?

No. The EJB specification particularly states that the enterprise bean is just not allowed to make use of thread primitives. The container is chargeable for managing concurrent entry to beans at runtime

Question 565. Is Method Overloading Allowed In Ejb?

Yes you may overload strategies

Question 566. What Is The Default Transaction Attribute For An Ejb?

There is not any default transaction attribute for an EJB. In weblogic, the default transaction attribute for EJB is SUPPORTS.

Question 567. Is It Possible To Stop The Execution Of A Method Before Completion In A Sessionbean?

Stopping the execution of a technique inside a Session Bean is just not potential with out writing code contained in the Session Bean. This is as a result of you aren’t allowed to entry Threads inside an EJB.

Question 568. What Do You Understand By The Term Network?

A community is a set of computer systems and peripherals, comparable to modems and printers, which might be bodily linked collectively. A specific community has a novel set of {hardware} and software program that permits varied computer systems and peripherals to speak. The energy of networks allows computer systems to share sources. For instance, a small pc on a community can entry and use different computer systems which might be far more highly effective.

One Java design aim was to help the event of complicated applications which might be small, bug free and straightforward to know. One of the areas wherein Java’s creators have succeeded with this aim is within the Network class. In different programming languages, performing the best community activity can require pages of codes. With Java, in distinction, many of those duties have been diminished to a single assertion. For instance, opening a file throughout a community in Java is just not far more sophisticated than opening an area file. Because of this ease in programming, Java ought to make community programming widespread place.

Question 569. Explain The Generic Term Internet.

The generic time period web refers to a community of networks. The Internet is only one explicit web. However, it’s the final community of networks. Because you have an interest in Java, you’ve got definitely used a Web browser to surf the Internet. As you most likely know, a Web browser is just one of many Internet purposes.
Other Internet purposes embody e-mail, community information, file transfers and telnet. Other than e-mail, some customers on the Web aren’t conscious of those different purposes. Each has performed an necessary position in getting the Internet the place it’s at this time. For instance, community information, additionally referred to as Usenet, remains to be a well-liked approach for customers to alternate data utilizing a bulletin-board like media. Usenet lets customers focus on a variety of matters.
In the early days, the Internet was developed by the educational group. Usenet and e-mail had been excellent for researchers to speak with one another throughout the nation. Today, Usenet matters cowl all features of human web and e-mail is an indispensable business software.

Question 570. What Does Tcp/ip Stand For And What Is Its Use?

To talk throughout the Internet, a program should comply with a selected algorithm, referred to as protocols. These protocols might specify the scale and format of this system’s digital messages or how applications synchronize messages. In brief, who sends the primary message and what kind of reply the sender expects.

The major protocol on the Internet is TCP/IP (the Transmission Control Protocol/Internet Protocol), The TCP/IP protocols outline the foundations that computer systems and peripherals on the Internet use to speak. For instance, TCP/IP protocols defines how a program finds a specific gadget on a community, the format this system should use to ship the gadget information, how this system ought to examine for errors and so forth.

Question 571. What Do You Understand By The Term Client-server Application?

Networks make many new kinds of purposes potential as a result of a single machine not has to do every part. Within a community, some computer systems, referred to as servers, carry out specialised duties on behalf of different applications. A program that makes use of a server is a shopper.
A server is just a pc that runs a selected program repeatedly whose position goal is to offer a service to different applications. A shopper, alternatively, is a program that receives service from the server. For instance, a print server is a software program program that waits till different applications (the purchasers) ship their information to print. The server then prints the information on behalf of the shopper. There are many kinds of servers throughout the Internet with which you’ll be acquainted, comparable to mail servers, file servers and naturally, World Wide (or HTTP) servers.

Question 572. What Are Protocols? What Are They Used For?

To write a client-server utility, you need to create two applications: the shopper and the server. Within these applications, you need to outline how the 2 purposes will talk—the foundations every program should comply with. As you’ve got realized, the foundations the shopper and server program should comply with to speak are protocols. In brief, protocols outline how client-server applications work together.
Most programmers implement protocols utilizing a sequence of layers, the place every layer offers with a specific activity. For instance, the bottom layer may take care of the precise communication throughout the community {hardware}. The subsequent layer may examine the bits despatched throughout the community for communication errors. Likewise, the subsequent layer may bundle the bits right into a message format your program understands. Client-server purposes use upper-layer protocols which might be usually based mostly on a selected utility (comparable to printing a file or transferring a file). The upper-layer protocol defines a strict algorithm on how two purposes alternate information.

Question 573. What Is The Relationship Between Servers And Ports?

As you’ve got realized, an IP tackle identifies a pc on the Internet. You additionally realized {that a} port quantity identifies a course of (a program) that’s working on a pc. As it seems, applications use port numbers for shopper and server purposes. Because IP addresses are distinctive and on a given pc, port numbers are distinctive, a port quantity mixed with an IP tackle utterly distinguishes an utility working on the Internet. The mixture of port quantity and IP tackle yields a socket and gives an finish level of a communication path. As you’ll be taught the identical utility IP tackle and port quantity might use a number of sockets, every having a distinct worth. Thus, a socket’s worth combines an application-specific worth with the IP tackle and port quantity.

Question 574. What Is The Applet Client Restriction?

Java locations restrictions on an applet. One restriction is that an applet can not make a Socket connection to any server apart from the one it got here from (the server from which the browser downloaded the applet). Therefore, you can not, for instance, make a generic mail software applet except you intend to help it with SMTP and POP3 mail servers on the identical machine that shops the applet. Also, due to this restriction, you can not have two applets join immediately collectively, in order that two customers can play a sport. Consequently, you must all the time take applet restrictions into consideration if you design a Java-server utility with applets.

Question 575. Why Servers Should Be Multithreading? Explain.

As you already know, multithreading lets your Java program carry out duties in parallel. A server is a good instance of a program that ought to be multithreaded. If a server has a single thread of management, just one shopper can work together with the server at anybody time. If you write your server to help multithreading, the server can course of many client-server connections concurrently.

Question 576. Why A Client Should Be Multithreading? Explain.

In many kinds of shopper purposes, help for a number of threads can be helpful. A Web browser, for instance, is a multithreaded utility. Within a browser, you may have a number of home windows open and carry out a number of downloads on the identical time. To carry out every obtain operation, the browser merely begins a brand new thread which preforms the corresponding processing.
When your program writes data to or receives data from a stream, a program that makes use of a single thread of management should await the I/O operation to finish—a course of referred to as I/O blocking. If you employ a number of threads to carry out the stream learn and write operations, your utility can proceed to carry out different operations. When you write shopper purposes, reap the benefits of Java’s multithreading to make your applications interface extra user-friendly and extra responsive.

Question 577. What Is Chat Area? Explain.

Ever because the first computer systems had been linked, folks have been utilizing them to speak. A chat space is an interface that lets a gaggle of individuals speak by typing messages. Like all Internet-based program, chat applications should comply with a selected protocol: Specifically, chat applications depend on the Internet Relay Chat (IRC) protocol. However, chatting on a Web web page has been ad-hoc at greatest, till Java.
With Java, a Web web page can have a completely featured chat space. Features comparable to instantaneous messages and membership rooms usually are not troublesome to implement. Due to the applet restrictions, chat applets on the identical web page should talk by way of a server on the pc the place they reside.

Question 578. What Are The Applet’s Life Cycle Methods? Explain Them.

Following are the strategies within the life cycle of an Applet:
(a) init() methodology—referred to as, when an applet is first loaded. This methodology is known as solely as soon as in the whole cycle of an applet. This methodology often initializes the variables for use within the applet.
(b) begin() methodology—referred to as every time an applet is began.
(c) paint() methodology—referred to as when the applet is minimized or refreshed. This methodology is used for drawing totally different strings, figures and pictures on the applet window.
(d) cease() methodology—referred to as when the browser strikes off the applet’s web page.
(e) destroy() methodology—referred to as when the browser is completed with the applet.

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

Question 580. What Are The Applet’s Information Methods?

The following are the Applet’s data strategies:

getAppletInfo() methodology: Returns a string describing the applet, its creator, copyright data, and many others.
getParameterInfo() methodology: Returns an array of string describing the applet’s parameters.
Question 581. How Does Ejb Invocation Happens?

Retrieve Home Object reference from Naming Service by way of JNDI. Return Home Object reference to the shopper. Create me a brand new EJB Object by way of Home Object interface. Create EJB Object from the Ejb Object. Return EJB Object reference to the shopper. Invoke business methodology utilizing EJB Object reference. Delegate request to Bean (Enterprise Bean).

Question 582. What Is Clustering? What Are The Different Algorithms Used For Clustering?

Clustering is grouping machines collectively to transparently present enterprise providers. The shopper doesn’t know the distinction between approaching one server or approaching a cluster of servers. Clusters present two advantages: scalability and excessive availability.


Spread the love