Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
nmims post
Objective Type Set
Online MCQ Assignment
Question Solution
Solved Question
Uncategorized

Java MCQ Set 1

1. What are exceptions?
a) Anomalous conditions requiring special processing
b) Extra methods written to increase functionality
c) Commented lines describing exceptional cases
d) Null objects

View Answer

Answer: a [Reason:] Exceptions result in disruption of the normal flow of the code execution

2. ________ can be useful in adding additional functionality which applies to every test within a test class.
a) Copy
b) Rules
c) Exceptions
d) Boundaries

View Answer

Answer: b [Reason:] JUnit rules intercept the test methods and give additional functionality.

3. ___ is a programming paradigm which allows the separation of cross cutting concerns, hence, increasing modularity.
a) Functional Programming
b) Object Oriented Programming
c) Aspect Oriented Programming
d) Data Injections

View Answer

Answer: c [Reason:] Aspect Oriented Programming adds additional behaviour to existing code by separately which code is modified using a cut-point specification.

4. ________ describes a class of functions which when run modify other functions.
a) Class
b) Advice
c) Modifiers
d) Changers

View Answer

Answer: b [Reason:] Advice is a certain method applied at a certain join of a code.

5. AOP forms a basis for ____
a) Functional Development
b) Object Oriented Programming
c) Datafield Development
d) Aspect Oriented Software Development

View Answer

Answer: d [Reason:] AOSD seeks modularization of systems.

6. Custom JUnit rules can be created using _____
a) TestRule Interface
b) CreateRule Interface
c) RuleCreate Interface
d) RuleInitialize Interface

View Answer

Answer: a [Reason:] JUnit provide the TestRule Interface which helps define custom JUnit Rules.

7. With the ‘expected’ argument, one cannot _____
a) Test a method
b) Test for exception type
c) Test the value of the message in the exception
d) Test for specific exception

View Answer

Answer: c [Reason:] The ‘expected’ argument cannot check the value of the message passed in the exception.

8. The ___ rule can be used to test both exception type and message.
a) Expected
b) ExpectedException
c) CatchException
d) Catch

View Answer

Answer: b [Reason:] Since JUnit 4.7, ExpectedException can be used to test both exception type and message.

9. ExpectedException is found under which package?
a) org.junit.ExpectedException
b) org.junit.Test.ExpectedException
c) org.junit.Rule.ExpectedException
d) org.junit.rules.ExpectedException

View Answer

Answer: d [Reason:] ExpectedException is a Rule and hence, is founde inside the rules package of JUnit.

10. The correct way to initialise an ExpectedException object is ____
a) public ExpectedException thrown = ExpectedException.none()
b) @Rule public ExpectedException thrown
c) @Rule public ExpectedException thrown = ExpectedException.none()
d) public ExpectedException thrown = ExpectedException.none()

View Answer

Answer: c [Reason:] The default value of no exception is assigned to the object during declaration.

Java MCQ Set 2

1. What is timeout testing?
a) Testing for exceptions
b) Testing code execution within time limits
c) Testing code correctness
d) Testing code with time functions

View Answer

Answer: b [Reason:] Timeout Testing checks if the code runs within specified time limits.

2. The _____ parameter is used along with the @Test annotation to test for timeouts.
a) Expected
b) Timeout
c) NoLimit
d) Time

View Answer

Answer: b [Reason:] Timeout Parameter specifies the maximum time each test method can take.

3. @Test(timeout = 130) implies a time limit of _____
a) 130 milliseconds
b) 130 minutes
c) 130 seconds
d) 1.30 minutes

View Answer

Answer: a [Reason:] The timeout argument is in milliseconds.

4. Timeout testing is ______
a) Software Dependent
b) Hardware Dependent
c) Software and Hardware Dependent
d) Software and Hardware Independent

View Answer

Answer: c [Reason:] Since different software and hardware gives different performance, timeout testing is software and hardware dependent.

5. What applies the same timeout to every test method of a class?
a) @Timeout
b) @Expected
c) Timeout Rule
d) Not possible to apply same timeout

View Answer

Answer: c [Reason:] The timeout can be specified as a rule so that it is applied to every method.

6. A Timeout Rule is initialized by ______
a) @Rule public Timeout object = new Timeout()
b) @Rule public Timeout object = Timeout.seconds()
c) public Timeout object = Timeout.seconds()
d) public Timeout object = new Timeout()

View Answer

Answer: b [Reason:] The correct way to initialise a Timeout Rules is using the Timeout.seconds() function.

7. Where is the Timeout class present?
a) org.junit.rules.Timeout
b) org.junit.Timeout
c) org.Timeout
d) org.junit.RuleClasses.Timeout

View Answer

Answer: a [Reason:] The correct package for the Timeout class is under org.junit.rules.

8. The Timeout Rule implements which interface?
a) Timeout
b) Test
c) TestingTimeout
d) TestRule

View Answer

Answer: d [Reason:] The TestRule interface is extended and implemented by Timeout Rule.

9. If a timeout which has been specified lapses before the completion of the test, its execution is interrupted with _______
a) Interrupt()
b) Thread.interrupt()
c) Thread.interruptable()
d) Threads.interruptable()

View Answer

Answer: b [Reason:] The timeout is brought about through Interruptible I/O and locks.

10. What does a specified timeout of 0 imply?
a) 130 milliseconds
b) 130 minutes
c) 130 seconds
d) Not set

View Answer

Answer: d [Reason:] A specified timeout of 0 implies that the Timeout is not set.

Java MCQ Set 3

1. Tag used to enable AspectJ annotation?
a) Introduction
b) aop:aspectj-autowire
c) aop:aspectj-autoproxy
d) AfterSpecial

View Answer

Answer: c [Reason:] To enable AspectJ annotation support in Spring, you have already defined an empty XML element, aop:aspectj-autoproxy.

2. Tag which defined Spring AOP configurations
a) aop:config
b) aop:configregister
c) aop:configbeans
d) None of the mentioned

View Answer

Answer: a [Reason:] In the bean configuration file, all the Spring AOP configurations must be defined inside the aop:config element.

3. What are the ways to declare an advice?
a) pointcut-ref attribute
b) pointcut attribute
c) all of the mentioned
d) none of the mentioned

View Answer

Answer: c [Reason:] An advice element requires either a pointcut-ref attribute to refer to a pointcut or a pointcut attribute to embed a pointcut expression directly.

4. Applying aspects to your target objects
a) AspectJ Annotation
b) Weaving
c) All of the mentioned
d) None of the mentioned

View Answer

Answer: b [Reason:] Weaving is the process of applying aspects to your target objects.

5. Special compiler used during weaving
a) jvm
b) gcc
c) ajc
d) none of the mentioned

View Answer

Answer: c [Reason:] AspectJ compile-time weaving is done through a special AspectJ compiler called ajc.

6. Name of the process when targe classes are loaded into JVM
a) load-time weaving
b) process-time weaving
c) load-process weaving
d) process-delivery weaving

View Answer

Answer: a [Reason:] AspectJ load-time weaving (also known as LTW) happens when the target classes are loaded into JVM by a class loader.

7. How to weave your classes using argument while compiling?
a) -javaagent:CLASSPATH
b) -javaagent:PackgePath
c) -javaweave:CLASSPATH
d) -javaweave:PackagePath

View Answer

Answer: a [Reason:] You need only to add a VM argument to the command that runs your application. Then your classes will get woven when they are loaded into the JVM.

8. XML Element to include load-time weaver
a) aop:config
b) aop:auto-wire
c) context:load-time-weaver
d) aop:load-time-weaver

View Answer

Answer: c [Reason:] To turn on a suitable load-time weaver for your Spring application, you need only to declare the empty XML element context:load-time-weaver.

9. You also have to include suitable load-time weaver’s configuration in XML
a) True
b) False

View Answer

Answer: b [Reason:] Spring will be able to detect the most suitable load-time weaver for your runtime environment.

10. Library to use AspectJ weaver
a) spring-instrument.jar
b) spring-introduction.jar
c) spring-aop.jar
d) spring-weave.jar

View Answer

Answer: a [Reason:] To use the AspectJ weaver, you need to include the spring-instrument.jar

11. Objects created outside the container:-
a) Domain Objects
b) User Objects
c) SpringVisitor Objects
d) None of the mentioned

View Answer

Answer: a [Reason:] Objects created outside the Spring IoC container are usually domain objects. They are often created using the new operator or from the results of database queries.

12. How to inject Spring bean into domain objcts
a) AOP
b) XML
c) AspectJ
d) Java Based

View Answer

Answer: a [Reason:] To inject a Spring bean into domain objects created outside Spring, you need the help of AOP.

13. We can directly use Spring AOP for injection of beans
a) True
b) False

View Answer

Answer: b [Reason:] As the domain objects are not created by Spring, you cannot use Spring AOP for injection.

14. Which scope does @Configurable instantiated class looks for?
a) Singleton
b) Prototype
c) None of the mentioned
d) All of the mentioned

View Answer

Answer: b [Reason:] When a class with the @Configurable annotation is instantiated, the aspect will look for a prototype-scoped bean definition whose type is the same as this class.

15. Spring includes AnnotationBeanConfigurerAspect in its aspect library for configuring the dependencies of any objects
a) True
b) False

View Answer

Answer: a [Reason:] Spring includes AnnotationBeanConfigurerAspect in its aspect library for configuring the dependencies of any objects, even if they were not created by the Spring IoC container. First of all, you have to annotate your object type with the @Configurable annotation to declare that this type of object is configurable.

Java MCQ Set 4

1. The endpoint’s url attribute defines where service is mounted.
a) endpoint’s url
b) endpoint
c) endpoint’s service
d) none of the mentioned

View Answer

Answer: a [Reason:] The endpoint’s url attribute defines where we should expect this service to be mounted.

2. To keep our code as ready-to-deploy as possible.
a) parameterize the URL of the service in the client
b) add an entry to your /etc/hosts file on Unix derivatives or, on Windows, to your C:WINDOWSsystem32driversetchosts
c) none of the mentioned
d) all of the mentioned

View Answer

Answer: d [Reason:] To keep our code as ready-to-deploy as possible, you should parameterize the URL of the service in the client. Alternatively, if you know the domain name for your application, you might add an entry to your /etc/hosts file on Unix derivatives or, on Windows, to your C:WINDOWSsystem32driversetchosts file mapping 127.0.0.1 to your target domain.

3. Spring BlazeDS creates existing Spring beans as AMF endpoints.
a) True
b) False

View Answer

Answer: a [Reason:] Spring BlazeDS lets you expose existing Spring beans as AMF endpoints.

4. The service, which will simply fetch all the items that are for auction and return the description.
a) SpringBlaze DS
b) SpringFlex
c) EventSpring
d) All of the mentioned

View Answer

Answer: a [Reason:] Use Spring BlazeDS to set up a simple service and demonstrate its invocation from the client—a simple auction application that we’ll build on in subsequent recipes.

5. To keep the code simpler.
a) Hibernate
b) Backing data store
c) ConcurrentSkipListSet
d) None of the mentioned

View Answer

Answer: c [Reason:] We’re not using Hibernate or any backing data store to keep the code simpler. Instead, the service uses a ConcurrentSkipListSet instance variable.

6. Method which takes parameters required to describe a bid and creates it.
a) bid
b) acceptBid
c) all of the mentioned
d) none of the mentioned

View Answer

Answer: a [Reason:] The bid method takes parameters required to describe a bid and creates it.

7. To notify other viewers of any new items posted.
a) javax.jms.Topic
b) jms
c) all of the mentioned
d) none of the mentioned

View Answer

Answer: c [Reason:] We want to notify other viewers of any new items posted, we use JMS and a javax.jms.Topic.

8. Method, which is called after the component’s been configured by Spring
a) setupItems
b) setUp
c) setupFakeItems
d) all of the mentioned

View Answer

Answer: c [Reason:] We spend some time constructing seed data in the setupFakeItems method, which is called after the component’s been configured by Spring.

9. To configurie the standard Spring bean.
a) context:component-scan
b) context:scan
c) context:component
d) none of the mentioned

View Answer

Answer: a [Reason:] There are two parts to the configuration: the standard services configuration, and the Spring BlazeDS configuration. We’ve already gone a long way to configuring the standard Spring beans with the addition of the context:component-scan element.

10. In Spring context XML for the message broker, we have.
a) flex
b) flex:message-broker
c) all of the mentioned
d) none of the mentioned

View Answer

Answer: b [Reason:] Recall that in our Spring context XML for the message broker, we had a flex:message-broker element, in which we had a flex:message-service element.

11. flex:message-service element had an attribute.
a) default-channels
b) default-channel
c) default
d) default-types

View Answer

Answer: a [Reason:] The flex:message-service element had an attribute, default-channels.

12. To use a different channel they’d like to use when communicating with the server.
a) flex:remoting-destination
b) flex:remote
c) flex:destination
d) flex:default-channels

View Answer

Answer: a [Reason:] If, however, you’d like to use a different channel, then you may override it on the flex:remoting-destination element.

13. In ActionScript, “dynamic” means that you can arbitrarily add or reference fields only.
a) True
b) False

View Answer

Answer: b [Reason:] In ActionScript, “dynamic” means that you can arbitrarily add or reference fields and methods on an object without type information.

14. ActionScript treats a class just like you could in the standard JavaScript.
a) True
b) False

View Answer

Answer: a [Reason:] In the browser, this behavior is called expando properties and these are useful for us because Flash doesn’t have any built-in way of knowing (and surfacing to tools like your IDE’s auto-completion) the type information of the returned object.

15. Spring BlazeDS works with Spring Integration to let you bind any arbitrary endpoint.
a) True
b) False

View Answer

Answer: a [Reason:] Spring BlazeDS works with Spring Integration to let you bind any arbitrary endpoint (be it an e-mail server, a Twitter user’s update feed, an FTP server, a file system, or anything for which you want to write an adapter) to the Spring BlazeDS messaging facilities.

Java MCQ Set 5

1. Interface implemented by locale resolver.
a) localeResolver
b) tiles
c) front controller
d) none of the mentioned

View Answer

Answer: a [Reason:] In a Spring MVC application, a user’s locale is identified by a locale resolver, which has to implement the LocaleResolver interface.

2. You can define a locale resolver by registering a bean of type LocaleResolver in the web application context.
a) True
b) False

View Answer

Answer: a [Reason:] You must set the bean name of the locale resolver to localeResolver for DispatcherServlet to auto-detect.

3. Default localeResolver used by Spring.
a) AcceptHeaderLocale
b) AcceptHeader
c) AcceptHeaderLocaleResolver
d) AcceptLocaleResolver

View Answer

Answer: c [Reason:] The default locale resolver used by Spring is AcceptHeaderLocaleResolver.

4. AcceptHeaderLocaleResolver esolves locales by inspecting the accept-language header of an HTTP request.
a) True
b) False

View Answer

Answer: a [Reason:] This header is set by a user’s web browser according to the locale setting of the underlying operating system.

5. Alternative way to resolve locales.
a) AcceptHeaderLocale
b) AcceptHeader
c) AcceptHeaderLocaleResolver
d) SessionLocaleResolver

View Answer

Answer: d [Reason:] Another option of resolving locales is by SessionLocaleResolver.

6. Property which indicates how many seconds this cookie should be persisted.
a) cookieMaxAge
b) cookieName
c) cookieAge
d) none of the mentioned

View Answer

Answer: a [Reason:] The cookieMaxAge property indicates how many seconds this cookie should be persisted.

7. Method used to change user’s locale.
a) set
b) setLocale
c) locale
d) set_locale

View Answer

Answer: b [Reason:] Changing a user’s locale by calling LocaleResolver.setLocale() explicitly.

8. Property of LocaleChangeInterceptor used to customize parameter name.
a) localeResolver.setLocale
b) paramName
c) locale.parm
d) none of the mentioned

View Answer

Answer: b [Reason:] Changing a user’s locale by calling LocaleResolver.setLocale() explicitly.

9. LocaleChangeInterceptor can only detect the parameter for the handler mappings that enable it.
a) True
b) False

View Answer

Answer: a [Reason:] So, if you have more than one handler mapping configured in your web application context, you have to register this interceptor to allow users to change their locales in any of the URLs.

10. Parameter which can change user’s locale by any URL.
a) locale
b) languageURL
c) language
d) none of the mentioned

View Answer

Answer: c [Reason:] Now a user’s locale can be changed by any URLs with the language parameter.

11. Interface used to resolve text messages.
a) Message
b) Message_Source
c) Language
d) MessageSource

View Answer

Answer: d [Reason:] Spring is able to resolve text messages for you by using a message source, which has to implement the MessageSource interface.

12. Tag used by view to resolve text messages.
a) spring:message
b) spring:language
c) spring:title
d) none of the mentioned

View Answer

Answer: a [Reason:] Then your JSP files can use the spring:message tag, defined in Spring’s tag library, to resolve a message given the code.

13. The ResourceBundleMessageSource implementation resolves messages for different locales.
a) True
b) False

View Answer

Answer: a [Reason:] The ResourceBundleMessageSource implementation resolves messages from different resource bundles for different locales.

14. cookieName is used by localeResolver to customize the cookie used.
a) True
b) False

View Answer

Answer: a [Reason:] The cookie used by this locale resolver can be customized by setting the cookieName and cookieMaxAge properties.

15. The cookieMaxAge value when browser is closed.
a) 0
b) 1
c) -1
d) true

View Answer

Answer: c [Reason:] The value -1 indicates that this cookie will be invalid after the browser is closed.

.woocommerce-message { background-color: #98C391 !important; }