JOBSEEKERS
Login
Sign Up
Jobseeker
Employer
Staffing Firm
Direct Client
Spring interview questions part 23
Spring interview questions part 23
Back
Take as many assements as you can to improve your validate your skill rating
Total Questions: 20
1. e static method to locate a platform MBean server. import java.lang.management.ManagementFactory; import javax.management.Descriptor; import javax.management.JMException; import javax.management.MBeanServer; import javax.management.ObjectName; import javax.management.modelmbean.DescriptorSupport; import javax.management.modelmbean.InvalidTargetObjectTypeException; import javax.management.modelmbean.ModelMBeanAttributeInfo; import javax.management.modelmbean.ModelMBeanInfo; import javax.management.modelmbean.ModelMBeanInfoSupport; import javax.management.modelmbean.ModelMBeanOperationInfo; import javax.management.modelmbean.RequiredModelMBean; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class Main { public static void main(String[] args) throws IOException { ApplicationContext context = new ClassPathXmlApplicationContext("beans-jmx.xml"); FileReplicator documentReplicator = (FileReplicator) context.getBean("documentReplicator"); try { MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer(); ObjectName objectName = new ObjectName("bean:name=documentReplicator"); RequiredModelMBean mbean = new RequiredModelMBean(); mbean.setManagedResource(documentReplicator, "objectReference"); Descriptor srcDirDescriptor = new DescriptorSupport(new String[] { "name=SrcDir", "descriptorType=attribute", "getMethod=getSrcDir", "setMethod=setSrcDir" }); ModelMBeanAttributeInfo srcDirInfo = new ModelMBeanAttributeInfo( "SrcDir", "java.lang.String", "Source directory", true, true, false, srcDirDescriptor); Descriptor destDirDescriptor = new DescriptorSupport(new String[] { "name=DestDir", "descriptorType=attribute", "getMethod=getDestDir", "setMethod=setDestDir" }); public static void main(String[] args) throws IOException { ApplicationContext context = new ClassPathXmlApplicationContext("beans-jmx.xml"); FileReplicator documentReplicator = (FileReplicator) context.getBean("documentReplicator"); ModelMBeanAttributeInfo destDirInfo = new ModelMBeanAttributeInfo( "DestDir", "java.lang.String", "Destination directory", true, true, false, destDirDescriptor); ModelMBeanOperationInfo getSrcDirInfo = new ModelMBeanOperationInfo( "Get source directory", FileReplicator.class.getMethod("getSrcDir")); ModelMBeanOperationInfo setSrcDirInfo = new ModelMBeanOperationInfo( "Set source directory", FileReplicator.class.getMethod("setSrcDir", String.class)); ModelMBeanOperationInfo getDestDirInfo = new ModelMBeanOperationInfo( "Get destination directory", FileReplicator.class.getMethod("getDestDir")); ModelMBeanOperationInfo setDestDirInfo = new ModelMBeanOperationInfo( "Set destination directory", FileReplicator.class.getMethod("setDestDir", String.class)); ModelMBeanOperationInfo replicateInfo = new ModelMBeanOperationInfo( "Replicate files", FileReplicator.class.getMethod("replicate")); ModelMBeanInfo mbeanInfo = new ModelMBeanInfoSupport( "FileReplicator", "File replicator", new ModelMBeanAttributeInfo[] { srcDirInfo, destDirInfo }, null, new ModelMBeanOperationInfo[] { getSrcDirInfo, setSrcDirInfo, getDestDirInfo, setDestDirInfo, replicateInfo }, null); mbean.setModelMBeanInfo(mbeanInfo); mbeanServer.registerMBean(mbean, objectName); } catch (JMException e) { ... } catch (InvalidTargetObjectTypeException e) { ... } catch (NoSuchMethodException e) { ... } System.in.read(); } }
A. ManagementFactory.getPlatform()
B. ManagementFactory.getPlatformMBeanServer()
C. ManagementFactory.getPlatformMBean()
D. All of the mentioned
Show Correct Answer
Correct Answer is :
ManagementFactory.getPlatformMBeanServer()
2. om the preceding code, you can see that for each MBean attribute and MBean operation, you need to create a:- import java.lang.management.ManagementFactory; import javax.management.Descriptor; import javax.management.JMException; import javax.management.MBeanServer; import javax.management.ObjectName; import javax.management.modelmbean.DescriptorSupport; import javax.management.modelmbean.InvalidTargetObjectTypeException; import javax.management.modelmbean.ModelMBeanAttributeInfo; import javax.management.modelmbean.ModelMBeanInfo; import javax.management.modelmbean.ModelMBeanInfoSupport; import javax.management.modelmbean.ModelMBeanOperationInfo; import javax.management.modelmbean.RequiredModelMBean; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class Main { public static void main(String[] args) throws IOException { ApplicationContext context = new ClassPathXmlApplicationContext("beans-jmx.xml"); FileReplicator documentReplicator = (FileReplicator) context.getBean("documentReplicator"); try { MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer(); ObjectName objectName = new ObjectName("bean:name=documentReplicator"); RequiredModelMBean mbean = new RequiredModelMBean(); mbean.setManagedResource(documentReplicator, "objectReference"); Descriptor srcDirDescriptor = new DescriptorSupport(new String[] { "name=SrcDir", "descriptorType=attribute", "getMethod=getSrcDir", "setMethod=setSrcDir" }); ModelMBeanAttributeInfo srcDirInfo = new ModelMBeanAttributeInfo( "SrcDir", "java.lang.String", "Source directory", true, true, false, srcDirDescriptor); Descriptor destDirDescriptor = new DescriptorSupport(new String[] { "name=DestDir", "descriptorType=attribute", "getMethod=getDestDir", "setMethod=setDestDir" }); public static void main(String[] args) throws IOException { ApplicationContext context = new ClassPathXmlApplicationContext("beans-jmx.xml"); FileReplicator documentReplicator = (FileReplicator) context.getBean("documentReplicator"); ModelMBeanAttributeInfo destDirInfo = new ModelMBeanAttributeInfo( "DestDir", "java.lang.String", "Destination directory", true, true, false, destDirDescriptor); ModelMBeanOperationInfo getSrcDirInfo = new ModelMBeanOperationInfo( "Get source directory", FileReplicator.class.getMethod("getSrcDir")); ModelMBeanOperationInfo setSrcDirInfo = new ModelMBeanOperationInfo( "Set source directory", FileReplicator.class.getMethod("setSrcDir", String.class)); ModelMBeanOperationInfo getDestDirInfo = new ModelMBeanOperationInfo( "Get destination directory", FileReplicator.class.getMethod("getDestDir")); ModelMBeanOperationInfo setDestDirInfo = new ModelMBeanOperationInfo( "Set destination directory", FileReplicator.class.getMethod("setDestDir", String.class)); ModelMBeanOperationInfo replicateInfo = new ModelMBeanOperationInfo( "Replicate files", FileReplicator.class.getMethod("replicate")); ModelMBeanInfo mbeanInfo = new ModelMBeanInfoSupport( "FileReplicator", "File replicator", new ModelMBeanAttributeInfo[] { srcDirInfo, destDirInfo }, null, new ModelMBeanOperationInfo[] { getSrcDirInfo, setSrcDirInfo, getDestDirInfo, setDestDirInfo, replicateInfo }, null); mbean.setModelMBeanInfo(mbeanInfo); mbeanServer.registerMBean(mbean, objectName); } catch (JMException e) { ... } catch (InvalidTargetObjectTypeException e) { ... } catch (NoSuchMethodException e) { ... } System.in.read(); } }
A. ModelMBeanAttributeInfo
B. ModelMBeanOperationInfo
C. None of the mentioned
D. All of the mentioned
Show Correct Answer
Correct Answer is :
All of the mentioned
3. VM argument to enable local monitoring of this application.
A. -Dcom.sun.management.jmxremote
B. -Dcom.sun.management
C. -Dcom.sun.management.jmx
D. None of the mentioned
Show Correct Answer
Correct Answer is :
-Dcom.sun.management.jmxremote
4. However, in an environment with no MBean server available, you have to create one explicitly using:-
A. MBeanServerFactoryBean
B. MBeanServerFactory
C. All of the mentioned
D. None of the mentioned
Show Correct Answer
Correct Answer is :
MBeanServerFactoryBean
5. Spring allows you to create a JMX connector server through:-
A. ConnectorServerFactoryBean
B. ConnectorServer
C. ConnectorServerFactory
D. All of the mentioned
Show Correct Answer
Correct Answer is :
ConnectorServerFactoryBean
6. ? should be replaced by:-
...
A. service:jmx:rmi://localhost/jndi/rmi://localhost:1099/replicator
B. service:jmx:rmi://localhost/jndi/rmi://localhost:1099/
C. service:jmx:rmi://localhost/jndi//localhost:1099/replicator
D. none of the mentioned
Show Correct Answer
Correct Answer is :
service:jmx:rmi://localhost/jndi/rmi://localhost:1099/replicator
7. If no RMI registry has been created externally, you should create one by using:-
A. RmiRegistryFactory
B. RmiRegistryFactoryBean
C. RmiRegistry
D. RmiRegister
Show Correct Answer
Correct Answer is :
RmiRegistryFactoryBean
8. The simplest MBean assembler in Spring is, which allows you to specify the names of the methods to export.
A. MethodNameBasedMBeanInfoAssembler
B. MethodNameBasedMBeanInfo
C. MethodNameBasedMBean
D. MethodNameBasedInfoAssembler
Show Correct Answer
Correct Answer is :
MethodNameBasedMBeanInfoAssembler
9. Spring allows your beans to publish JMX notifications through:-
A. NotificationPublisher
B. Notification
C. Notify
D. All of the mentioned
Show Correct Answer
Correct Answer is :
NotificationPublisher
10. Payload format for REST services.
A. RSS
B. Atom
C. JSON
D. All of the mentioned
Show Correct Answer
Correct Answer is :
All of the mentioned
11. All REST service payloads rely on XML markup.
A. TRUE
B. FALSE
C.
D.
Show Correct Answer
Correct Answer is :
FALSE
12. Class that forms part of Spring to apply JSON content.
A. MappingJacksonJsonView
B. MappingJsonView
C. MappingJacksonJson
D. JsonView
Show Correct Answer
Correct Answer is :
MappingJacksonJsonView
13. The MappingJacksonJsonView class depends on Jackson JSON processor library.
A. org.codehaus.jackson
B. jackson-mapper-asl
C. all of the mentioned
D. none of the mentioned
Show Correct Answer
Correct Answer is :
org.codehaus.jackson
14. Information you wish to publishas a JSON Object can be located in a RDBMS or text file, accessed through JDBC or ORM.
A. TRUE
B. FALSE
C.
D.
Show Correct Answer
Correct Answer is :
TRUE
15. JSON payload consists of text and separators like.
A. { , }
B. ( , )
C. :
D. All of the mentioned
Show Correct Answer
Correct Answer is :
All of the mentioned
16. To access JSON in a Spring application, library used is:-
A. JSON-LIB
B. SpringJSON-lib
C. JSON-lib
D. None of the mentioned
Show Correct Answer
Correct Answer is :
JSON-LIB
17. You are often better served accessing and manipulating REST services with XML payloads in Spring applications.
A. TRUE
B. FALSE
C.
D.
Show Correct Answer
Correct Answer is :
TRUE
18. Class which is capable of performing a multitude of operations on REST services.
A. RestTemplate
B. XPathTemplate
C. XMLTemplate
D. JavaTemplate
Show Correct Answer
Correct Answer is :
RestTemplate
19. XML query language for selecting nodes from an XML document.
A. XPathTemplate
B. XPath
C. All of the mentioned
D. None of the mentioned
Show Correct Answer
Correct Answer is :
XPath
20. The Handler method assigns the returning XML payload to a String.
A. TRUE
B. FALSE
C.
D.
Show Correct Answer
Correct Answer is :
TRUE
Similar Interview Questions
Search for latest jobs
Find Jobs