This section includes 7 InterviewSolutions, each offering curated multiple-choice questions to sharpen your Current Affairs knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Which Classes And Interfaces Does Applet Class Consists? |
|
Answer» Applet CLASS consists of a SINGLE class, the Applet class and three INTERFACES: AppletContext, AppletStub, and AudioClip. Applet class consists of a single class, the Applet class and three interfaces: AppletContext, AppletStub, and AudioClip. |
|
| 2. |
Can Applets On Different Pages Communicate With Each Other? |
|
Answer» Use the getSize() method, which the Applet class inherits from the COMPONENT class in the Java.awt package. The getSize() method returns the size of the applet as a DIMENSION object, from which you EXTRACT separate width, height fields. The following code SNIPPET explains this: Use the getSize() method, which the Applet class inherits from the Component class in the Java.awt package. The getSize() method returns the size of the applet as a Dimension object, from which you extract separate width, height fields. The following code snippet explains this: |
|
| 3. |
How Do I Select A Url From My Applet And Send The Browser To That Page? |
|
Answer» Ask the applet for its applet context and invoke showDocument() on that context object. Ask the applet for its applet context and invoke showDocument() on that context object. |
|
| 4. |
How Can I Arrange For Different Applets On A Web Page To Communicate With Each Other? |
|
Answer» Name your APPLETS INSIDE the Applet TAG and INVOKE AppletContexts getApplet() method in your applet code to obtain references to the other applets on the PAGE. Name your applets inside the Applet tag and invoke AppletContexts getApplet() method in your applet code to obtain references to the other applets on the page. |
|
| 5. |
How Do We Read Number Information From My Applets Parameters, Given That Applets Getparameter() Method Returns A String? |
|
Answer» Use the parseInt() method in the Integer CLASS, the Float(STRING) CONSTRUCTOR or parseFloat() method in the Class Float, or the DOUBLE(String) constructor or parseDoulbl() method in the class Double. Use the parseInt() method in the Integer Class, the Float(String) constructor or parseFloat() method in the Class Float, or the Double(String) constructor or parseDoulbl() method in the class Double. |
|
| 6. |
Can We Pass Parameters To An Applet From Html Page To An Applet? How? |
|
Answer» We can pass parameters to an applet USING <param> tag in the following way: We can pass parameters to an applet using <param> tag in the following way: |
|
| 7. |
How Do Applets Differ From Applications? |
|
Answer» Following are the main differences: Following are the main differences: |
|
| 8. |
What Is The Sequence For Calling The Methods By Awt For Applets? |
|
Answer» When an applet begins, the AWT CALLS the following methods, in this SEQUENCE: When an applet begins, the AWT calls the following methods, in this sequence: |
|
| 9. |
What Are The Applets Life Cycle Methods? Explain Them? |
|
Answer» methods in the life cycle of an Applet: methods in the life cycle of an Applet: |
|
| 10. |
What Is The Order Of Method Invocation In An Applet? |
|
Answer» ► public void init() : Initialization method called once by browser. ► public void init() : Initialization method called once by browser. |
|
| 11. |
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? |
|
Answer» SINCE 2.00 version our applets support an user-defined delimiter for the menu ARGUMENTS. To modify the default delimiter add the following parameter (you can use any character as a delimiter): <param name="delimiter" value="~"> and use it within "menuItems": <param name="menuItems" value=" {Home~http://www.wisdomjobs.com.com/index.php} {FEATURES,Setup~http://www.wisdomjobs.com/} ">Since 2.00 version our applets support an user-defined delimiter for the menu arguments. To modify the default delimiter add the following parameter (you can use any character as a delimiter): |
|
| 12. |
How To Insert Your Applets Into Frontpage? |
|
Answer» 1. PLACE the .class file in the DIRECTORY containing the HTML document into which you want to insert the applet. 1. Place the .class file in the directory containing the HTML document into which you want to insert the applet. |
|
| 13. |
How Will You Initialize An Applet? |
|
Answer» Write my INITIALIZATION code in the APPLETS INIT method or applet constructor. Write my initialization code in the applets init method or applet constructor. |
|
| 14. |
What Is An Applet? Should Applets Have Constructors? |
|
Answer» Applets are small programs transferred through Internet, AUTOMATICALLY installed and run as part of web-browser. Applets IMPLEMENTS functionality of a client. APPLET is a DYNAMIC and interactive program that runs inside a Web page displayed by a Java-capable browser. We dont have the concept of Constructors in Applets. Applets can be invoked EITHER through browser or through Appletviewer utility provided by JDK. Applets are small programs transferred through Internet, automatically installed and run as part of web-browser. Applets implements functionality of a client. Applet is a dynamic and interactive program that runs inside a Web page displayed by a Java-capable browser. We dont have the concept of Constructors in Applets. Applets can be invoked either through browser or through Appletviewer utility provided by JDK. |
|
| 15. |
How Do You Communicate In Between Applets And Servlets? |
|
Answer» We can USE the java.net.URLConnection and java.net.URL classes to open a standard HTTP connection and "tunnel" to the web SERVER. The server then passes this information to the servlet in the normal way. BASICALLY, the applet pretends to be a web browser, and the servlet doesn't know the difference. As FAR as the servlet is concerned, the applet is just another HTTP client. We can use the java.net.URLConnection and java.net.URL classes to open a standard HTTP connection and "tunnel" to the web server. The server then passes this information to the servlet in the normal way. Basically, the applet pretends to be a web browser, and the servlet doesn't know the difference. As far as the servlet is concerned, the applet is just another HTTP client. |
|
| 16. |
How Will You Communicate Between Two Applets? |
|
Answer» The simplest method is to use the STATIC variables of a SHARED class since there's only one instance of the class and hence only one copy of its static variables. A slightly more RELIABLE method relies on the fact that all the APPLETS on a given page share the same AppletContext. We obtain this applet context as follows: AppletContext ac = getAppletContext(); AppletContext provides applets with methods such as getApplet(name), getApplets(),getAudioClip, getImage, showDocument and showStatus(). The simplest method is to use the static variables of a shared class since there's only one instance of the class and hence only one copy of its static variables. A slightly more reliable method relies on the fact that all the applets on a given page share the same AppletContext. We obtain this applet context as follows: AppletContext ac = getAppletContext(); AppletContext provides applets with methods such as getApplet(name), getApplets(),getAudioClip, getImage, showDocument and showStatus(). |
|
| 17. |
What Are The General Considerations Or Best Practices For Defining Your Hibernate Persistent Classes? |
|
Answer» 1.You must have a default no-argument constructor for your persistent classes and there should be getXXX() (i.e accessor/getter) and setXXX( i.e. mutator/setter) methods for all your persistable instance variables. 1.You must have a default no-argument constructor for your persistent classes and there should be getXXX() (i.e accessor/getter) and setXXX( i.e. mutator/setter) methods for all your persistable instance variables. |
|
| 18. |
How Would You Reatach Detached Objects To A Session When The Same Object Has Already Been Loaded Into The Session? |
|
Answer» You can USE the session.merge() METHOD CALL. You can use the session.merge() method call. |
|
| 19. |
What Is The Difference Between The Session.update() Method And The Session.lock() Method? |
|
Answer» Both of these methods and saveOrUpdate() method are intended for reattaching a detached object. The session.lock() method simply reattaches the object to the session without checking or updating the database on the assumption that the database in sync with the detached object. It is the BEST practice to use either session.update(..) or session.saveOrUpdate(). Use session.lock() only if you are absolutely sure that the detached object is in sync with your detached object or if it does not matter because you will be OVERWRITING all the columns that would have CHANGED later on within the same transaction. Note: When you reattach detached objects you need to MAKE sure that the dependent objects are reatched as well. Both of these methods and saveOrUpdate() method are intended for reattaching a detached object. The session.lock() method simply reattaches the object to the session without checking or updating the database on the assumption that the database in sync with the detached object. It is the best practice to use either session.update(..) or session.saveOrUpdate(). Use session.lock() only if you are absolutely sure that the detached object is in sync with your detached object or if it does not matter because you will be overwriting all the columns that would have changed later on within the same transaction. Note: When you reattach detached objects you need to make sure that the dependent objects are reatched as well. |
|
| 20. |
What Is The Difference Between The Session.get() Method And The Session.load() Method? |
|
Answer» Both the session.get(..) and session.load() methods create a PERSISTENT OBJECT by LOADING the required object from the database. But if there was not such object in the database then the method session.load(..) throws an exception whereas session.get(&) returns NULL. Both the session.get(..) and session.load() methods create a persistent object by loading the required object from the database. But if there was not such object in the database then the method session.load(..) throws an exception whereas session.get(&) returns null. |
|
| 21. |
How Does Hibernate Distinguish Between Transient (i.e. Newly Instantiated) And Detached Objects? |
|
Answer» Hibernate uses the version property, if there is one. If not uses the identifier VALUE. No identifier value means a new object. This does WORK only for Hibernate managed surrogate KEYS. Does not work for NATURAL keys and assigned (i.e. not managed by Hibernate) surrogate keys. Write your own STRATEGY with Interceptor.isUnsaved(). Hibernate uses the version property, if there is one. If not uses the identifier value. No identifier value means a new object. This does work only for Hibernate managed surrogate keys. Does not work for natural keys and assigned (i.e. not managed by Hibernate) surrogate keys. Write your own strategy with Interceptor.isUnsaved(). |
|
| 22. |
What Are The Pros And Cons Of Detached Objects? |
|
Answer» Pros: Pros: |
|
| 23. |
What Are The Benefits Of Detached Objects? |
|
Answer» Detached objects can be passed ACROSS layers all the WAY up to the PRESENTATION layer WITHOUT having to use any DTOs (Data Transfer Objects). You can later on re-attach the detached objects to another session. Detached objects can be passed across layers all the way up to the presentation layer without having to use any DTOs (Data Transfer Objects). You can later on re-attach the detached objects to another session. |
|
| 24. |
What Is A Session? Can You Share A Session Object Between Different Theads? |
|
Answer» Session is a light weight and a non-threadsafe object (No, you cannot share it between threads) that represents a single unit-of-work with the database. Sessions are opened by a SessionFactory and then are closed when all work is complete. Session is the primary interface for the persistence service. A session obtains a database connection lazily (i.e. only when required). To avoid creating too many sessions ThreadLocal class can be used as shown below to get the CURRENT session no matter how many times you make CALL to the currentSession() method. Session is a light weight and a non-threadsafe object (No, you cannot share it between threads) that represents a single unit-of-work with the database. Sessions are opened by a SessionFactory and then are closed when all work is complete. Session is the primary interface for the persistence service. A session obtains a database connection lazily (i.e. only when required). To avoid creating too many sessions ThreadLocal class can be used as shown below to get the current session no matter how many times you make call to the currentSession() method. |
|
| 25. |
What Is A Sessionfactory? Is It A Thread-safe Object? |
|
Answer» SESSIONFACTORY is Hibernates concept of a single DATASTORE and is threadsafe so that many threads can ACCESS it concurrently and request for sessions and immutable cache of compiled mappings for a single database. A SessionFactory is usually only built once at STARTUP. SessionFactory should be wrapped in some kind of singleton so that it can be easily accessed in an application CODE. SessionFactory is Hibernates concept of a single datastore and is threadsafe so that many threads can access it concurrently and request for sessions and immutable cache of compiled mappings for a single database. A SessionFactory is usually only built once at startup. SessionFactory should be wrapped in some kind of singleton so that it can be easily accessed in an application code. |
|
| 26. |
How Will You Configure Hibernate? |
|
Answer» The configuration files hibernate.cfg.xml (or hibernate.properties) and mapping files *.hbm.xml are used by the Configuration class to create (i.e. configure and bootstrap hibernate) the SessionFactory, which in turn creates the Session instances. Session instances are the primary interface for the persistence service. " hibernate.cfg.xml (alternatively can use hibernate.properties): These two files are used to configure the hibernate sevice (connection DRIVER class, connection URL, connection username, connection password, dialect etc). If both files are present in the classpath then hibernate.cfg.xml file overrides the settings found in the hibernate.properties file. " Mapping files (*.hbm.xml): These files are used to map persistent objects to a relational database. It is the best practice to store each object in an individual mapping file (i.e mapping file per class) because storing LARGE number of persistent classes into one mapping file can be DIFFICULT to manage and maintain. The naming convention is to use the same name as the persistent (POJO) class name. For EXAMPLE Account.class will have a mapping file named Account.hbm.xml. Alternatively hibernate annotations can be used as part of your persistent class code instead of the *.hbm.xml files. The configuration files hibernate.cfg.xml (or hibernate.properties) and mapping files *.hbm.xml are used by the Configuration class to create (i.e. configure and bootstrap hibernate) the SessionFactory, which in turn creates the Session instances. Session instances are the primary interface for the persistence service. " hibernate.cfg.xml (alternatively can use hibernate.properties): These two files are used to configure the hibernate sevice (connection driver class, connection URL, connection username, connection password, dialect etc). If both files are present in the classpath then hibernate.cfg.xml file overrides the settings found in the hibernate.properties file. " Mapping files (*.hbm.xml): These files are used to map persistent objects to a relational database. It is the best practice to store each object in an individual mapping file (i.e mapping file per class) because storing large number of persistent classes into one mapping file can be difficult to manage and maintain. The naming convention is to use the same name as the persistent (POJO) class name. For example Account.class will have a mapping file named Account.hbm.xml. Alternatively hibernate annotations can be used as part of your persistent class code instead of the *.hbm.xml files. |
|
| 27. |
Explain The Difference Between Hibernate And Spring. |
|
Answer» Hibernate is an ORM tool for data persistency. Spring is a framework for ENTERPRISE applications. Spring supports hibernate and provides the different CLASSES which are templates that CONTAINS the common CODE. Hibernate is an ORM tool for data persistency. Spring is a framework for enterprise applications. Spring supports hibernate and provides the different classes which are templates that contains the common code. |
|
| 28. |
Explain The Main Difference Between Entity Beans And Hibernate. |
|
Answer» Entity beans are to be implemented by CONTAINERS, CLASSES, descriptors. Hibernate is just a tool that quickly persist the object tree to a class hierarchy in a database and without using a single SQL STATEMENT. The inheritance and polymorphism is quite simply implemented in hibernate which is out of the box of EJB and a big DRAWBACK. Entity beans are to be implemented by containers, classes, descriptors. Hibernate is just a tool that quickly persist the object tree to a class hierarchy in a database and without using a single SQL statement. The inheritance and polymorphism is quite simply implemented in hibernate which is out of the box of EJB and a big drawback. |
|
| 29. |
Why Hibernate Is Advantageous Over Entity Beans & Jdbc? |
|
Answer» An ENTITY bean always WORKS under the EJB container, which allows reusing of the object external to the container. An object can not be detached in entity beans and in hibernate detached objects are supported. Hibernate is not database DEPENDENT where as JDBC is database dependent. QUERY tuning is not needed for hibernate as JDBC is needed. Data can be placed in multiple cache which is supported by hibernate, whereas in JDBC the cache is to be implemented. An entity bean always works under the EJB container, which allows reusing of the object external to the container. An object can not be detached in entity beans and in hibernate detached objects are supported. Hibernate is not database dependent where as JDBC is database dependent. Query tuning is not needed for hibernate as JDBC is needed. Data can be placed in multiple cache which is supported by hibernate, whereas in JDBC the cache is to be implemented. |
|
| 30. |
What Is The Advantage Of Hibernate Over Jdbc? |
|
Answer» The advantages of Hibernate over JDBC are: The advantages of Hibernate over JDBC are: |
|
| 31. |
What Is The Difference Between Merge And Update? |
|
Answer» update () : When the session does not contain an persistent INSTANCE with the same identifier, and if it is sure use update for the DATA PERSISTENCE in hibernate. merge (): Irrespective of the state of a session, if there is a need to save the MODIFICATIONS at any given time, use merge(). update () : When the session does not contain an persistent instance with the same identifier, and if it is sure use update for the data persistence in hibernate. merge (): Irrespective of the state of a session, if there is a need to save the modifications at any given time, use merge(). |
|
| 32. |
State The Role Of Sessionfactory Interface Plays In Hibernate. |
|
Answer» • An application obtains Session instances from a SessionFactory which is typically single for the whole application created during its INITIALIZATION. • An application obtains Session instances from a SessionFactory which is typically single for the whole application created during its initialization. |
|
| 33. |
Explain The Role Of Session Interface In Hibernate. |
|
Answer» • In hibernate, the Session interface wraps a JDBC CONNECTION, holds a mandatory (first-level) cache of persistent objects, used when NAVIGATING the object graph or LOOKING up objects by IDENTIFIER and is a factory for Transaction. • In hibernate, the Session interface wraps a JDBC connection, holds a mandatory (first-level) cache of persistent objects, used when navigating the object graph or looking up objects by identifier and is a factory for Transaction. |
|
| 34. |
Explain The General Flow Of Hibernate Communication With Rdbms. |
|
Answer» The general flow of HIBERNATE communication with RDBMS is : The general flow of Hibernate communication with RDBMS is : |
|
| 35. |
What Is Hibernate Query Language (hql)? |
|
Answer» Hibernate Query Language is designed for data management using Hibernate TECHNOLOGY. It is completely object ORIENTED and hence has NOTIONS like inheritance, polymorphism and abstraction. The queries are case-sensitive. This has an EXCEPTION for Java classes and properties. The query operations are through objects. HQL acts as a BRIDGE between Objects and RDBMS. Hibernate Query Language is designed for data management using Hibernate technology. It is completely object oriented and hence has notions like inheritance, polymorphism and abstraction. The queries are case-sensitive. This has an exception for Java classes and properties. The query operations are through objects. HQL acts as a bridge between Objects and RDBMS. |
|
| 36. |
Explain The Advantages And Disadvantages Of Detached Objects. |
|
Answer» Advantages: Disadvantages: Advantages: Disadvantages: |
|
| 37. |
What Is The Difference Between Sorted And Ordered Collection In Hibernate? |
|
Answer» Sorted Collection: The less the collection the more the efficient of sorting. Ordered Collection: The more the collection, the more efficient of sorting. Sorted Collection: The less the collection the more the efficient of sorting. Ordered Collection: The more the collection, the more efficient of sorting. |
|
| 38. |
What Is Lazy Fetching In Hibernate? |
|
Answer» • Lazy SETTING decides whether to load child objects while loading the Parent OBJECT. • Lazy setting decides whether to load child objects while loading the Parent Object. |
|
| 39. |
What Is Lazy Initialization In Hibernate? |
|
Answer» The delaying the object creation or calculating a value or some PROCESS until the first time it is needed. The retrieval of particular information only at the time when the object is accessed, is lazy initialization in HIBERNATE. A scenario for lazy initialization is: When the field creation is EXPENSIVE, a field may or may not be invoked. In this scenario the creation of a field can be deferred until the actual moment is arise to use it. The performance is increased using this technique, by avoiding unnecessary creation of objects which is expensive and consumes the MEMORY space. The delaying the object creation or calculating a value or some process until the first time it is needed. The retrieval of particular information only at the time when the object is accessed, is lazy initialization in hibernate. A scenario for lazy initialization is: When the field creation is expensive, a field may or may not be invoked. In this scenario the creation of a field can be deferred until the actual moment is arise to use it. The performance is increased using this technique, by avoiding unnecessary creation of objects which is expensive and consumes the memory space. |
|
| 40. |
What Are Collection Types In Hibernate? |
|
Answer» • ArrayType, • ArrayType, |
|
| 41. |
Explain The Types Of Hibernate Instance States. |
|
Answer» The PERSISTENT class’s instance can be in any one of the three different states. These states are defined with a persistence context. The Hibernate has the FOLLOWING instance states: The persistent class’s instance can be in any one of the three different states. These states are defined with a persistence context. The Hibernate has the following instance states: |
|
| 42. |
What Is Hibernate Proxy? |
|
Answer» Mapping of classes can be made into a PROXY instead of a table. A proxy is returned when actually a LOAD is called on a session. The proxy contains actual method to load the data. The proxy is created by default by Hibernate, for mapping a class to a FILE. The code to invoke Jdbc is contained in this class. Mapping of classes can be made into a proxy instead of a table. A proxy is returned when actually a load is called on a session. The proxy contains actual method to load the data. The proxy is created by default by Hibernate, for mapping a class to a file. The code to invoke Jdbc is contained in this class. |
|
| 43. |
What Are The Benefits Of Hibernatetemplate? |
|
Answer» The BENEFITS of HibernateTemplate are: The benefits of HibernateTemplate are: |
|
| 44. |
What Is A Hibernatetemplate? |
|
Answer» HibernateTemplate is a HELPER class that is used to simplify the data access code. This class supports automatically converts HibernateExceptions which is a checked EXCEPTION into DataAccessExceptions which is an unchecked exception. HibernateTemplate is typically used to implement data access or BUSINESS logic services. The central method is EXECUTE(), that supports the Hibernate code that implements HibernateCallback interface. HibernateTemplate is a helper class that is used to simplify the data access code. This class supports automatically converts HibernateExceptions which is a checked exception into DataAccessExceptions which is an unchecked exception. HibernateTemplate is typically used to implement data access or business logic services. The central method is execute(), that supports the Hibernate code that implements HibernateCallback interface. |
|
| 45. |
What Are The Core Interfaces Of Hibernate Framework? |
|
Answer» 1. Session Interface: The basic interface for all hibernate applications. The instances are light weighted and can be created and destroyed without expensive process. 1. Session Interface: The basic interface for all hibernate applications. The instances are light weighted and can be created and destroyed without expensive process. |
|
| 46. |
What Are The Main Advantages Of Orm Like Hibernate? |
|
Answer» Hibernate IMPLEMENTS extremely high-concurrency architecture with no resource-contention issues. This architecture scales extremely well as concurrency increases in a cluster or on a single machine. Other performance related optimizations that hibernate performs are: Hibernate implements extremely high-concurrency architecture with no resource-contention issues. This architecture scales extremely well as concurrency increases in a cluster or on a single machine. Other performance related optimizations that hibernate performs are: |
|
| 47. |
Why Do You Need Orm Tool Like Hibernate? |
|
Answer» ORM TOOLS like hibernate provide FOLLOWING BENEFITS: ORM tools like hibernate provide following benefits: |
|
| 48. |
What Are Managed Associations And Hibernate Associations? |
|
Answer» ASSOCIATIONS that are related to container MANAGEMENT persistence are CALLED managed associations. These are bi-directional associations. Coming to hibernate associations, these are UNIDIRECTIONAL. Associations that are related to container management persistence are called managed associations. These are bi-directional associations. Coming to hibernate associations, these are unidirectional. |
|
| 49. |
What Are The Different Approaches To Represent An Inheritance Hierarchy? |
|
Answer» i. Table PER concrete CLASS. i. Table per concrete class. |
|
| 50. |
What Are The Different Methods Of Identifying An Object? |
|
Answer» There are three methods by which an object can be identified. There are three methods by which an object can be identified. |
|