Spring Questions and Answers – Logging and Unit Testing

«
»

This set of Java Spring Multiple Choice Questions & Answers (MCQs) focuses on “Logging and Unit Testing”.

1. To perform its logging operations.
a) Log4J
b) LogingJ
c) JLog
d) None of the mentioned
View Answer

Answer: a
Explanation: Grails relies on Java Log4J to perform its logging operations.
advertisement

2. Log4J configuration parameters are specified inside:-
a) Config.groovy
b) Conf.groovy
c) Log.groovy
d) None of the mentioned
View Answer

Answer: a
Explanation: Log4J configuration parameters are specified inside the Config.groovy file.

3. Grails application logging can be configured using:-
a) creating custom appenders
b) logging levels
c) console output
d) all of the mentioned
View Answer

Answer: d
Explanation: Given Log4J’s logging versatility, a Grails application logging can be configured in various ways. This includes creating custom appenders, logging levels, console output, logging by artifacts and custom logging layouts.

4. Any logging operation occurring at any of the cited packages will be logged.
a) True
b) False
View Answer

Answer: a
Explanation: The notation follows the convention logging level ‘package name’. This implies that any logging operation occurring at any of the cited packages will be logged so long as it occurs within the specified logging level or a more severe level.

5. In Log4J parlance, each package is known as:-
a) parlance
b) logger
c) all of the mentioned
d) none of the mentioned
View Answer

Answer: b
Explanation: In Log4J parlance, each package is known as a logger.
advertisement

6. Log4J also has the following logging level:-
a) fatal
b) error
c) warning
d) all of the mentioned
View Answer

Answer: d
Explanation: Log4J also has the following logging levels:
fatal, error, warn, info, debug, and trace. fatal is the most severe.

7. By default, all logging message are sent to the stacktrace.groovy file.
a) True
b) False
View Answer

Answer: a
Explanation: By default, all logging message are sent to the stacktrace.log file located under an application’s root directory.

8. To offer versatile logging functionality:-
a) loggers
b) appenders
c) all of the mentioned
d) none of the mentioned
View Answer

Answer: c
Explanation: Log4J relies on appenders and loggers to offer versatile logging functionality.

9. A location where logging information is sent.
a) appender
b) logger
c) all of the mentioned
d) none of the mentioned
View Answer

Answer: a
Explanation: An appender is a location where logging information is sent (e.g., a file or standard output).
advertisement

10. A location where logging information is generated.
a) appender
b) logger
c) all of the mentioned
d) none of the mentioned
View Answer

Answer: b
Explanation: A logger is a location where logging information is generated (e.g., a class or package).

11. The default Log4J logger can be customized in a Grails application.
a) True
b) False
View Answer

Answer: a
Explanation: The default Log4J logger can be customized in a Grails application using the following statement within the log4j { } section of an application’s Config.groovy file:
root {
error()
additivity = true
}

12. An appender that logs to a JDBC connection.
a) jdbc
b) console
c) file
d) rollingFile
View Answer

Answer: a
Explanation: There are four types of appenders available by default:
• jdbc : An appender that logs to a JDBC connection
• console: An appender that logs to standard output
• file: An appender that logs to a file.
• rollingFile: An appender that logs to a rolling set of files

13. Command for running tests in Grails.
a) grails test-app
b) grails test
c) grails test-app domain class
d) none of the mentioned
View Answer

Answer: a
Explanation: Running tests in Grails is as simple as executing the grails test-app command from an application’s root directory.
advertisement

14. Unit tests are designed to validate the logic contained in a single domain class.
a) True
b) False
View Answer

Answer: a
Explanation: Because of this fact, besides automating the execution of such tests, Grails provides no type of bootstrapping properties for performing these type of tests.

15. Method creates a mock object from a domain class.
a) mockForConstraintsTests
b) mockForConstraints
c) all of the mentioned
d) none of the mentioned
View Answer

Answer: a
Explanation: This method creates a mock object from a domain class that is used to access a class’s dynamic methods (e.g., validate) needed to perform unit tests.

Sanfoundry Global Education & Learning Series – Java Spring.
To practice all areas of Java Spring, here is complete set of 1000+ Multiple Choice Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

advertisement
advertisement
advertisement
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn