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
Explanation: Grails relies on Java Log4J to perform its logging operations.
2. Log4J configuration parameters are specified inside:-
a) Config.groovy
b) Conf.groovy
c) Log.groovy
d) None of the mentioned
View Answer
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
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
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
Explanation: In Log4J parlance, each package is known as a logger.
6. Log4J also has the following logging level:-
a) fatal
b) error
c) warning
d) all of the mentioned
View Answer
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
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
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
Explanation: An appender is a location where logging information is sent (e.g., a file or standard output).
10. A location where logging information is generated.
a) appender
b) logger
c) all of the mentioned
d) none of the mentioned
View Answer
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
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
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
Explanation: Running tests in Grails is as simple as executing the grails test-app command from an application’s root directory.
14. Unit tests are designed to validate the logic contained in a single domain class.
a) True
b) False
View Answer
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
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.
- Get Free Certificate of Merit in Spring
- Participate in Spring Certification Contest
- Become a Top Ranker in Spring
- Take Spring Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Apply for Spring Internship
- Apply for Programming Internship
- Buy Spring Books
- Practice Programming MCQs
- Buy Information Technology Books