250+ TOP MCQs on Logging and Unit Testing and Answers

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

1. To perform its logging operations.
a) Log4J
b) LogingJ
c) JLog
d) None of the mentioned
Answer: a
Clarification: 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
Answer: a
Clarification: 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
Answer: d
Clarification: 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
Answer: a
Clarification: 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
Answer: b
Clarification: 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
Answer: d
Clarification: 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
Answer: a
Clarification: 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
Answer: c
Clarification: 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
Answer: a
Clarification: 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
Answer: b
Clarification: 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
Answer: a
Clarification: 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
Answer: a
Clarification: 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
Answer: a
Clarification: 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
Answer: a
Clarification: 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
Answer: a
Clarification: 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.

Leave a Reply

Your email address will not be published. Required fields are marked *