Java MCQ Set 1
1. Key technology in developing distributed applications, especially multitier enterprise applications.
a) Remoting
b) EJB
c) RMI
d) All of the mentioned
Answer
Answer: d [Reason:] Spring’s support for various remoting technologies, such as EJB, RMI, Hessian, Burlap, HTTP Invoker, and web services. Remoting is a key technology in developing distributed applications, especially multitier enterprise applications.
2. Java-based remoting technology that allows two Java applications running in different JVMs to communicate with each other.
a) Burlap
b) EJB
c) RMI
d) All of the mentioned
Answer
Answer: c [Reason:] With RMI, an object can invoke the methods of a remote object. RMI relies on object serialization to marshall and unmarshall method arguments and return values.
3. To expose a service through RMI, you have to create the service interface that extends:-
a) java.rmi.Remote
b) java.rmi.RemoteException
c) all of the mentioned
d) none of the mentioned
Answer
Answer: a [Reason:] Considering the typical RMI usage scenario, to expose a service through RMI, you have to create the service interface that extends java.rmi.Remote and whose methods declare throwing java.rmi.RemoteException.
4. To call the methods on a remote service:-
a) java.rmi.Remote
b) java.rmi.RemoteException
c) all of the mentioned
d) none of the mentioned
Answer
Answer: b [Reason:] However, to call the methods on a remote service, you must handle java.rmi.RemoteException in case any exception is thrown by the remote service.
5. Spring’s remoting facilities can significantly simplify the RMI usage on both the server and client sides.
a) True
b) False
Answer
Answer: a [Reason:] On the server side, you can use RmiServiceExporter to export a Spring bean as an RMI service whose methods can be invoked remotely. It’s just several lines of bean configuration without any programming. On the client side, you can simply use RmiProxyFactoryBean to create a proxy for the remote service.
6. There are several properties you must configure for an RmiServiceExporter instance:-
a) service name
b) service interface
c) service object
d) all of the mentioned
Answer
Answer: d [Reason:] There are several properties you must configure for an RmiServiceExporter instance, including the service name, the service interface, and the service object to export.
7. By default, RmiServiceExporter attempts to look up an RMI registry at localhost port 1099.
a) True
b) False
Answer
Answer: a [Reason:] If it can’t find the RMI registry, it will start a new one.
8. The Spring support classes facilitate building session beans:-
a) stateful session beans (SFSBs)
b) stateless session beans (SLSBs)
c) message-driven beans (MDBs)
d) all of the mentioned
Answer
Answer: d [Reason:] The Spring support classes facilitate building session beans—stateful session beans (SFSBs) and stateless session beans (SLSBs)—and message-driven beans (MDBs) with Spring.
9. Spring’s EJB Support Classes for Different Types of EJB:-
a) AbstractStatelessSessionBean
b) AbstractStatefulSessionBean
c) AbstractMessageDrivenBean
d) All of the mentioned
Answer
Answer: d [Reason:] Spring’s EJB Support Classes for Different Types of EJB
EJB Support Class EJB Type
AbstractStatelessSessionBean Stateless session bean
AbstractStatefulSessionBean Stateful session bean
AbstractMessageDrivenBean General message-driven bean that may not use JMS
AbstractJmsMessageDrivenBean Message-driven bean that uses JMS.
10. EJB support classes provide access to the Spring IoC container for you to implement your business logic in POJOs and wrap them with EJB components.
a) True
b) False
Answer
Answer: a [Reason:] Because POJOs are easier to develop and test, implementing business logic in POJOs can accelerate your EJB development.
11. OpenEJB 3.1.1 supports:-
a) EJB 2.x components
b) EJB 3.0 and EJB 3.1 components
c) All of the mentioned
d) None of the mentioned
Answer
Answer: c [Reason:] To compile and build your EJB component, you have to include a library that contains standard EJB classes and interfaces in your classpath. OpenEJB 3.1.1 supports both legacy EJB 2.x components as well as newer EJB 3.0 and EJB 3.1 components, so we’ll use its implementation library.
12. If you want to expose EJB component for local access within an enterprise application, the preceding two interfaces should extend EJBLocalObject and EJBLocalHome.
a) True
b) False
Answer
Answer: a [Reason:] If you want to expose this EJB component for local access within an enterprise application, the preceding two interfaces should extend EJBLocalObject and EJBLocalHome instead, whose methods don’t need to throw RemoteException. For simplicity’s sake, we’re omitting the local and local home interfaces here.
13. The ejbCreate() method is the EJB hook for initialization of state, much as a JSR-250 annotated @PostConstruct() method or afterPropertiesSet() method work in Java EE 5 and Spring.
a) True
b) False
Answer
Answer: a [Reason:] Similarly, for each overloaded form of ejbCreate() on the SessionBean, there must be a create method with the same arguments on the EJBHome.
14. To start the OpenEJB container, you first set environment variable:-
a) EJB_HOME
b) OPENEJB_HOME
c) Bashrc
d) None of the mentioned
Answer
Answer: b [Reason:] To start the OpenEJB container, you first set the OPENEJB_HOME environment variable to point to your OpenEJB installation directory.
15. To use Spring’s EJB support for your EJB implementation classes, you have to include a few Spring framework JARs:-
a) spring-beans
b) spring-core
c) spring-context
d) all of the mentioned
Answer
Answer: d [Reason:] To use Spring’s EJB support for your EJB implementation classes, you have to include a few Spring framework JARs, including spring-beans, spring-core, spring-context, spring-asm, and spring-expression in the classpath of your EJB container.
Java MCQ Set 2
1. Key technology in developing distributed applications, especially multitier enterprise applications.
a) Remoting
b) EJB
c) RMI
d) All of the mentioned
Answer
Answer: d [Reason:] Spring’s support for various remoting technologies, such as EJB, RMI, Hessian, Burlap, HTTP Invoker, and web services. Remoting is a key technology in developing distributed applications, especially multitier enterprise applications.
2. Java-based remoting technology that allows two Java applications running in different JVMs to communicate with each other.
a) Burlap
b) EJB
c) RMI
d) All of the mentioned
Answer
Answer: c [Reason:] With RMI, an object can invoke the methods of a remote object. RMI relies on object serialization to marshall and unmarshall method arguments and return values.
3. To expose a service through RMI, you have to create the service interface that extends:-
a) java.rmi.Remote
b) java.rmi.RemoteException
c) all of the mentioned
d) none of the mentioned
Answer
Answer: a [Reason:] Considering the typical RMI usage scenario, to expose a service through RMI, you have to create the service interface that extends java.rmi.Remote and whose methods declare throwing java.rmi.RemoteException.
4. To call the methods on a remote service:-
a) java.rmi.Remote
b) java.rmi.RemoteException
c) all of the mentioned
d) none of the mentioned
Answer
Answer: b [Reason:] However, to call the methods on a remote service, you must handle java.rmi.RemoteException in case any exception is thrown by the remote service.
5. Spring’s remoting facilities can significantly simplify the RMI usage on both the server and client sides.
a) True
b) False
Answer
Answer: a [Reason:] On the server side, you can use RmiServiceExporter to export a Spring bean as an RMI service whose methods can be invoked remotely. It’s just several lines of bean configuration without any programming. On the client side, you can simply use RmiProxyFactoryBean to create a proxy for the remote service.
6. There are several properties you must configure for an RmiServiceExporter instance:-
a) service name
b) service interface
c) service object
d) all of the mentioned
Answer
Answer: d [Reason:] There are several properties you must configure for an RmiServiceExporter instance, including the service name, the service interface, and the service object to export.
7. By default, RmiServiceExporter attempts to look up an RMI registry at localhost port 1099.
a) True
b) False
Answer
Answer: a [Reason:] If it can’t find the RMI registry, it will start a new one.
8. The Spring support classes facilitate building session beans:-
a) stateful session beans (SFSBs)
b) stateless session beans (SLSBs)
c) message-driven beans (MDBs)
d) all of the mentioned
Answer
Answer: d [Reason:] The Spring support classes facilitate building session beans—stateful session beans (SFSBs) and stateless session beans (SLSBs)—and message-driven beans (MDBs) with Spring.
9. Spring’s EJB Support Classes for Different Types of EJB:-
a) AbstractStatelessSessionBean
b) AbstractStatefulSessionBean
c) AbstractMessageDrivenBean
d) All of the mentioned
Answer
Answer: d [Reason:] Spring’s EJB Support Classes for Different Types of EJB
EJB Support Class EJB Type
AbstractStatelessSessionBean Stateless session bean
AbstractStatefulSessionBean Stateful session bean
AbstractMessageDrivenBean General message-driven bean that may not use JMS
AbstractJmsMessageDrivenBean Message-driven bean that uses JMS.
10. EJB support classes provide access to the Spring IoC container for you to implement your business logic in POJOs and wrap them with EJB components.
a) True
b) False
Answer
Answer: a [Reason:] Because POJOs are easier to develop and test, implementing business logic in POJOs can accelerate your EJB development.
11. OpenEJB 3.1.1 supports:-
a) EJB 2.x components
b) EJB 3.0 and EJB 3.1 components
c) All of the mentioned
d) None of the mentioned
Answer
Answer: c [Reason:] To compile and build your EJB component, you have to include a library that contains standard EJB classes and interfaces in your classpath. OpenEJB 3.1.1 supports both legacy EJB 2.x components as well as newer EJB 3.0 and EJB 3.1 components, so we’ll use its implementation library.
12. If you want to expose EJB component for local access within an enterprise application, the preceding two interfaces should extend EJBLocalObject and EJBLocalHome.
a) True
b) False
Answer
Answer: a [Reason:] If you want to expose this EJB component for local access within an enterprise application, the preceding two interfaces should extend EJBLocalObject and EJBLocalHome instead, whose methods don’t need to throw RemoteException. For simplicity’s sake, we’re omitting the local and local home interfaces here.
13. The ejbCreate() method is the EJB hook for initialization of state, much as a JSR-250 annotated @PostConstruct() method or afterPropertiesSet() method work in Java EE 5 and Spring.
a) True
b) False
Answer
Answer: a [Reason:] Similarly, for each overloaded form of ejbCreate() on the SessionBean, there must be a create method with the same arguments on the EJBHome.
14. To start the OpenEJB container, you first set environment variable:-
a) EJB_HOME
b) OPENEJB_HOME
c) Bashrc
d) None of the mentioned
Answer
Answer: b [Reason:] To start the OpenEJB container, you first set the OPENEJB_HOME environment variable to point to your OpenEJB installation directory.
15. To use Spring’s EJB support for your EJB implementation classes, you have to include a few Spring framework JARs:-
a) spring-beans
b) spring-core
c) spring-context
d) all of the mentioned
Answer
Answer: d [Reason:] To use Spring’s EJB support for your EJB implementation classes, you have to include a few Spring framework JARs, including spring-beans, spring-core, spring-context, spring-asm, and spring-expression in the classpath of your EJB container.
Java MCQ Set 3
1. Interceptor to let Spring configure @Autowired elements on your EJB.
a) org.springframework.ejb.interceptor.SpringBeanAutowiringInterceptor
b) org.springframework.ejb.interceptor.SpringBeanAutowiring
c) org.springframework.ejb.interceptor.SpringBean
d) none of the mentioned
Answer
Answer: a [Reason:] Use the org.springframework.ejb.interceptor.SpringBeanAutowiringInterceptor interceptor to let Spring configure @Autowired elements on your EJB.
2. A remote stateless session bean requires annotations:-
a) @Remote
b) @Stateless
c) All of the mentioned
d) None of the mentioned
Answer
Answer: c [Reason:] A remote stateless session bean requires the @Stateless and @Remote annotations. In the @Remote annotation, you have to specify the remote interface for this EJB component.
3. Proxying Spring services with EJB3s, injecting custom resources configured in Spring, or even using Spring to isolate your EJBs from acquiring references to other distributed resources such as a REST endpoint or an RMI endpoint.
a) SpringBeanAutowiringInterceptor
b) SpringBeanAutowiring
c) SpringBean
d) SpringBeanInterceptor
Answer
Answer: a [Reason:] To do this, use Spring’s SpringBeanAutowiringInterceptor class to provide configuration for the EJB.
4. Annotation which decorates the PostageServiceBean:-
a) @Interceptors
b) @Autowire
c) @Wire
d) @Mention
Answer
Answer: a [Reason:] This tells Spring to handle @Autowired injection points in the class.
5. The interceptor obtains beans, by default, from a ContextSingletonBeanFactoryLocation.
a) True
b) False
Answer
Answer: a [Reason:] The interceptor obtains beans, by default, from a ContextSingletonBeanFactoryLocation, which in turn looks for an XML application context named beanRefContext.xml, which is presumed to be on the classpath.
6. EJB interface is a simple Java interface whose methods don’t throw RemoteException.
a) True
b) False
Answer
Answer: a [Reason:] EJB interface is a simple Java interface whose methods don’t throw RemoteException, while the implementation class is a simple Java class annotated with EJB annotations.
7. To declare a JNDI object reference in the Spring IoC container.
a) JndiObjectFactory
b) JndiObjectFactoryBean
c) JndiObject
d) JndiFactoryBean
Answer
Answer: b [Reason:] By using Spring’s JndiObjectFactoryBean, you can easily declare a JNDI object reference in the Spring IoC container. You can use this factory bean to declare a reference to an EJB 3.0 component.
8. The default JNDI name for a remote EJB 3.0 component is the EJB class name with Remote as its suffix .
a) True
b) False
Answer
Answer: a [Reason:] If you have chosen OpenEJB as your EJB container, the default JNDI name for a remote EJB 3.0 component is the EJB class name with Remote as its suffix (PostageServiceBeanRemote, in this case).
9. You can configure the JNDI details for factory bean in:-
a) jndiEnvironment
b) jndiName
c) all of the mentioned
d) none of the mentioned
Answer
Answer: c [Reason:] You can configure the JNDI details for factory bean in the jndiEnvironment and jndiName properties.
10. Lightweight remoting technologies developed by Caucho Technology.
a) Hessian
b) Burlap
c) All of the mentioned
d) None of the mentioned
Answer
Answer: c [Reason:] Hessian and Burlap are two simple lightweight remoting technologies developed by Caucho Technology (http://www.caucho.com/).
11. Spring framework itself also offers a remoting technology called HTTP Invoker.
a) True
b) False
Answer
Answer: a [Reason:] It also communicates over HTTP, but uses Java’s object serialization mechanism to serialize objects.
12. To expose a Hessian or Burlap service, you have to add the:-
a) Hessian library
b) Burlap library
c) All of the mentioned
d) None of the mentioned
Answer
Answer: c [Reason:] To expose a Hessian or Burlap service, you have to add the Hessian library to your classpath.
13. For a HessianServiceExporter instance, you have to configure a service object to export and its service interface.
a) True
b) False
Answer
Answer: a [Reason:] You can export any bean configured in the IoC container as a Hessian service, and HessianServiceExporter will create a proxy to wrap this bean.
14. By default, BeanNameUrlHandlerMapping is preconfigured for a Spring MVC application.
a) True
b) False
Answer
Answer: a [Reason:] It maps requests to handlers according to the URL patterns specified as bean names.
15. Invoking a Burlap service:-
a) HessianProxyFactoryBean
b) BurlapProxyFactoryBean
c) BurlapProxyFactory
d) BurlapProxy
Answer
Answer: b [Reason:] Invoking a Burlap service is very similar to Hessian. The only difference is that you should use BurlapProxyFactoryBean.
Java MCQ Set 4
1. Interceptor to let Spring configure @Autowired elements on your EJB.
a) org.springframework.ejb.interceptor.SpringBeanAutowiringInterceptor
b) org.springframework.ejb.interceptor.SpringBeanAutowiring
c) org.springframework.ejb.interceptor.SpringBean
d) none of the mentioned
Answer
Answer: a [Reason:] Use the org.springframework.ejb.interceptor.SpringBeanAutowiringInterceptor interceptor to let Spring configure @Autowired elements on your EJB.
2. A remote stateless session bean requires annotations:-
a) @Remote
b) @Stateless
c) All of the mentioned
d) None of the mentioned
Answer
Answer: c [Reason:] A remote stateless session bean requires the @Stateless and @Remote annotations. In the @Remote annotation, you have to specify the remote interface for this EJB component.
3. Proxying Spring services with EJB3s, injecting custom resources configured in Spring, or even using Spring to isolate your EJBs from acquiring references to other distributed resources such as a REST endpoint or an RMI endpoint.
a) SpringBeanAutowiringInterceptor
b) SpringBeanAutowiring
c) SpringBean
d) SpringBeanInterceptor
Answer
Answer: a [Reason:] To do this, use Spring’s SpringBeanAutowiringInterceptor class to provide configuration for the EJB.
4. Annotation which decorates the PostageServiceBean:-
a) @Interceptors
b) @Autowire
c) @Wire
d) @Mention
Answer
Answer: a [Reason:] This tells Spring to handle @Autowired injection points in the class.
5. The interceptor obtains beans, by default, from a ContextSingletonBeanFactoryLocation.
a) True
b) False
Answer
Answer: a [Reason:] The interceptor obtains beans, by default, from a ContextSingletonBeanFactoryLocation, which in turn looks for an XML application context named beanRefContext.xml, which is presumed to be on the classpath.
6. EJB interface is a simple Java interface whose methods don’t throw RemoteException.
a) True
b) False
Answer
Answer: a [Reason:] EJB interface is a simple Java interface whose methods don’t throw RemoteException, while the implementation class is a simple Java class annotated with EJB annotations.
7. To declare a JNDI object reference in the Spring IoC container.
a) JndiObjectFactory
b) JndiObjectFactoryBean
c) JndiObject
d) JndiFactoryBean
Answer
Answer: b [Reason:] By using Spring’s JndiObjectFactoryBean, you can easily declare a JNDI object reference in the Spring IoC container. You can use this factory bean to declare a reference to an EJB 3.0 component.
8. The default JNDI name for a remote EJB 3.0 component is the EJB class name with Remote as its suffix .
a) True
b) False
Answer
Answer: a [Reason:] If you have chosen OpenEJB as your EJB container, the default JNDI name for a remote EJB 3.0 component is the EJB class name with Remote as its suffix (PostageServiceBeanRemote, in this case).
9. You can configure the JNDI details for factory bean in:-
a) jndiEnvironment
b) jndiName
c) all of the mentioned
d) none of the mentioned
Answer
Answer: c [Reason:] You can configure the JNDI details for factory bean in the jndiEnvironment and jndiName properties.
10. Lightweight remoting technologies developed by Caucho Technology.
a) Hessian
b) Burlap
c) All of the mentioned
d) None of the mentioned
Answer
Answer: c [Reason:] Hessian and Burlap are two simple lightweight remoting technologies developed by Caucho Technology (http://www.caucho.com/).
11. Spring framework itself also offers a remoting technology called HTTP Invoker.
a) True
b) False
Answer
Answer: a [Reason:] It also communicates over HTTP, but uses Java’s object serialization mechanism to serialize objects.
12. To expose a Hessian or Burlap service, you have to add the:-
a) Hessian library
b) Burlap library
c) All of the mentioned
d) None of the mentioned
Answer
Answer: c [Reason:] To expose a Hessian or Burlap service, you have to add the Hessian library to your classpath.
13. For a HessianServiceExporter instance, you have to configure a service object to export and its service interface.
a) True
b) False
Answer
Answer: a [Reason:] You can export any bean configured in the IoC container as a Hessian service, and HessianServiceExporter will create a proxy to wrap this bean.
14. By default, BeanNameUrlHandlerMapping is preconfigured for a Spring MVC application.
a) True
b) False
Answer
Answer: a [Reason:] It maps requests to handlers according to the URL patterns specified as bean names.
15. Invoking a Burlap service:-
a) HessianProxyFactoryBean
b) BurlapProxyFactoryBean
c) BurlapProxyFactory
d) BurlapProxy
Answer
Answer: b [Reason:] Invoking a Burlap service is very similar to Hessian. The only difference is that you should use BurlapProxyFactoryBean.
Java MCQ Set 5
1. IntelliJ’s IDEA product, versions 8 and 9, supports:-
a) Flex
b) AIR
c) None of the mentioned
d) All of the mentioned
Answer
Answer: d [Reason:] Particularly, IntelliJ’s IDEA product, versions 8 and 9, support Flex and AIR development with aplomb.
2. Flex is that it is, technically, a library implemented on top of the middleware.
a) True
b) False
Answer
Answer: b [Reason:] Flex is, technically, a library implemented on top of the Flash virtual machine.
3. In Flash, the displayed area where animation and rendering occurs.
a) Stage
b) Animation
c) Stagery
d) State
Answer
Answer: a [Reason:] In Flash, the displayed area where animation and rendering occurs is called the stage.
4. Flex uses a language called ActionScript 3.0.
a) True
b) False
Answer
Answer: b [Reason:] Flash uses a language called ActionScript 3.0.
5. ActionScript code pages end in .as, and ActionScript binaries are .sf files.
a) True
b) False
Answer
Answer: b [Reason:] ActionScript code pages end in .as, and ActionScript binaries are .swf files.
6. Linkable libraries have the extension.
a) .swc
b) .dll
c) .so
d) none of the mentioned
Answer
Answer: a [Reason:] You can use ActionScript tools to build linkable libraries, much like a .dll on Windows, or a .so on Linux. These linkable libraries have the extension .swc.
7. The source artifacts of a Flex application are:-
a) ActionScript files (ending in .as)
b) ActionScript files (ending in .mxml)
c) All of the mentioned
d) None of the mentioned
Answer
Answer: c [Reason:] The two source artifacts of a Flex application are the ActionScript files (ending in .as) and the .mxml files.
8. XML variant that describe the UI components and provide a DOM.
a) AS files
b) MXML files
c) XML Files
d) All of the mentioned
Answer
Answer: b [Reason:] MXML files are an XML variant that describe the UI components and provide a DOM.
9. MXML files support a limited form of expression language binding
a) True
b) False
Answer
Answer: a [Reason:] Limited when compared to the EL support in frameworks like Tapestry or JSF, anyway.
10. Outermost tag in Flex.
a) mx:Application
b) mx:WindowedApplication
c) all of the mentioned
d) none of the mentioned
Answer
Answer: a [Reason:] In the case of Flex applications, the outermost tag is the mx:Application tag.
11. Outermost tag in AIR.
a) mx:Application
b) mx:WindowedApplication
c) all of the mentioned
d) none of the mentioned
Answer
Answer: b [Reason:] In the case of AIR applications, the outermost tag is the mx:WindowedApplication tag.
12. As soon as the application has been loaded and all the objects configured, an event will be fired.
a) applicationEvent
b) applicationComplete
c) eventConfigure
d) eventComplete
Answer
Answer: b [Reason:] Just as you can in the browser, you have two choices for listening to events in Flex: programmatic registration and through MXML attributes on the component that fires the event.
13. JavaScript library dynamically adds the plug-in content to the page.
a) True
b) False
Answer
Answer: a [Reason:] Because of this property, it triggered the “Dynamic Content” warning in Internet Explorer 6 for a few years.
14. JavaScript library dynamically generates.
a) object
b) plugin
c) FlashVars
d) all of the mentioned
Answer
Answer: d [Reason:] The library dynamically generates the relevant object and plugin tags, along with the FlashVars parameters.
15.To talk to the containing HTML page.
a) flash.external.ExternalInterface
b) flash.external.External
c) flash.external.ExternalInterface
d) none of the mentioned
Answer
Answer: a [Reason:] To talk to the containing HTML page, you can use the flash.external.ExternalInterface class. This class defines two static methods, call() (which lets the Flex application talk to the host) and addCallback() (which lets the host talk to Flex).