- log4j Tutorial
- log4j - Home
- log4j - Overview
- log4j - Installation
- log4j - Architecture
- log4j - Configuration
- log4j - Sample Program
- log4j - Logging Methods
- log4j - Logging Levels
- log4j - Log Formatting
- log4j - Logging in Files
- log4j - Logging in Database
- log4j Useful Resources
- log4j - Questions and Answers
- log4j - Quick Guide
- log4j - Useful Resources
- log4j - Discussion
log4j Mock Test
This section presents you various set of Mock Tests related to log4j Framework. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.
log4j Mock Test II
Q 1 - Which of the following method of logger print a log message in info mode?
A - public void debug(Object message)
B - public void error(Object message)
Answer : D
Explanation
public void info(Object message) of Logger class prints messages with the level Level.INFO.
Q 2 - Which of the following method of logger print a log message in warn mode?
A - public void warn(Object message)
B - public void error(Object message)
Answer : A
Explanation
public void warn(Object message) of Logger class prints messages with the level Level.WARN.
Q 3 - Which of the following method of logger print a log message in trace mode?
A - public void warn(Object message)
B - public void trace(Object message)
Answer : B
Explanation
public void trace(Object message) of Logger class prints messages with the level Level.TRACE.
Q 4 - Which of the following level designates fine-grained informational events that are most useful to debug an application?
Answer : A
Explanation
DEBUG − Designates fine-grained informational events that are most useful to debug an application.
Q 5 - Which of the following level designates error events that might still allow the application to continue running?
Answer : B
Explanation
ERROR − Designates error events that might still allow the application to continue running.
Q 6 - Which of the following level designates very severe error events that will presumably lead the application to abort?
Answer : C
Explanation
FATAL − Designates very severe error events that will presumably lead the application to abort.
Q 7 - Which of the following level designates informational messages that highlight the progress of the application at coarse-grained level?
Answer : D
Explanation
INFO − Designates informational messages that highlight the progress of the application at coarse-grained level.
Q 8 - Which of the following level is intended to turn off logging?
Answer : A
Explanation
OFF − The highest possible rank and is intended to turn off logging.
Q 9 - Which of the following level designates finer-grained informational events than the DEBUG?
Answer : B
Explanation
TRACE − Designates finer-grained informational events than the DEBUG.
Q 10 - Which of the following level designates potentially harmful situations?
Answer : C
Explanation
WARN − Designates potentially harmful situations.
Q 11 - Which of the following level designates all levels including custom levels?
Answer : D
Explanation
ALL − All levels including custom levels.
Q 12 - Which of the following is true about log4j levels?
A - A log request of level p in a logger with level q is enabled if p >= q.
B - A log request assumes that levels are ordered.
C - For the standard levels, we have ALL < DEBUG < INFO < WARN < ERROR < FATAL < OFF.
Answer : D
Explanation
All of the above options are correct.
Q 13 - Which of the following is true about PatternLayout object?
Answer : C
Explanation
Both of the above options are correct.
Q 14 - What is the purpose of c character used in the conversionPattern of PatternLayout object?
A - Used to output the category of the logging event.
B - Used to output the fully qualified class name of the caller issuing the logging request.
C - Used to output the date of the logging event.
D - Used to output the file name where the logging request was issued.
Answer : A
Explanation
c − Used to output the category of the logging event. For example, for the category name "a.b.c" the pattern %c{2} will output "b.c".
Q 15 - What is the purpose of C character used in the conversionPattern of PatternLayout object?
A - Used to output the category of the logging event.
B - Used to output the fully qualified class name of the caller issuing the logging request.
C - Used to output the date of the logging event.
D - Used to output the file name where the logging request was issued.
Answer : B
Explanation
C − Used to output the fully qualified class name of the caller issuing the logging request. For example, for the class name.* "org.apache.xyz.SomeClass", the pattern %C{1} will output "SomeClass".
Q 16 - What is the purpose of d character used in the conversionPattern of PatternLayout object?
A - Used to output the category of the logging event.
B - Used to output the fully qualified class name of the caller issuing the logging request.
C - Used to output the date of the logging event.
D - Used to output the file name where the logging request was issued.
Answer : C
Explanation
d − Used to output the date of the logging event. For example, %d{HH:mm:ss,SSS} or %d{dd MMM yyyy HH:mm:ss,SSS}.
Q 17 - What is the purpose of F character used in the conversionPattern of PatternLayout object?
A - Used to output the category of the logging event.
B - Used to output the fully qualified class name of the caller issuing the logging request.
C - Used to output the date of the logging event.
D - Used to output the file name where the logging request was issued.
Answer : D
Explanation
F − Used to output the file name where the logging request was issued.
Q 18 - What is the purpose of l character used in the conversionPattern of PatternLayout object?
A - Used to output location information of the caller which generated the logging event.
B - Used to output the line number from where the logging request was issued.
C - Used to output the application supplied message associated with the logging event.
D - Used to output the method name where the logging request was issued.
Answer : A
Explanation
l − Used to output location information of the caller which generated the logging event.
Q 19 - What is the purpose of L character used in the conversionPattern of PatternLayout object?
A - Used to output location information of the caller which generated the logging event.
B - Used to output the line number from where the logging request was issued.
C - Used to output the application supplied message associated with the logging event.
D - Used to output the method name where the logging request was issued.
Answer : B
Explanation
L − Used to output the line number from where the logging request was issued.
Q 20 - What is the purpose of m character used in the conversionPattern of PatternLayout object?
A - Used to output location information of the caller which generated the logging event.
B - Used to output the line number from where the logging request was issued.
C - Used to output the application supplied message associated with the logging event.
D - Used to output the method name where the logging request was issued.
Answer : C
Explanation
m − Used to output the application supplied message associated with the logging event.
Q 21 - What is the purpose of M character used in the conversionPattern of PatternLayout object?
A - Used to output location information of the caller which generated the logging event.
B - Used to output the line number from where the logging request was issued.
C - Used to output the application supplied message associated with the logging event.
D - Used to output the method name where the logging request was issued.
Answer : D
Explanation
M − Used to output the method name where the logging request was issued.
Q 22 - What is the purpose of n character used in the conversionPattern of PatternLayout object?
A - Outputs the platform dependent line separator character or characters.
B - Used to output the priority of the logging event.
D - Used to output the name of the thread that generated the logging event.
Answer : A
Explanation
n − Outputs the platform dependent line separator character or characters.
Q 23 - What is the purpose of p character used in the conversionPattern of PatternLayout object?
A - Outputs the platform dependent line separator character or characters.
B - Used to output the priority of the logging event.
D - Used to output the name of the thread that generated the logging event.
Answer : B
Explanation
p − Used to output the priority of the logging event.
Q 24 - What is the purpose of r character used in the conversionPattern of PatternLayout object?
A - Outputs the platform dependent line separator character or characters.
B - Used to output the priority of the logging event.
D - Used to output the name of the thread that generated the logging event.
Answer : C
Explanation
r − Used to output the number of milliseconds elapsed from the construction of the layout until the creation of the logging event.
Q 25 - What is the purpose of t character used in the conversionPattern of PatternLayout object?
A - Outputs the platform dependent line separator character or characters.
B - Used to output the priority of the logging event.
D - Used to output the name of the thread that generated the logging event.
Answer : D
Explanation
t − Used to output the name of the thread that generated the logging event.
Answer Sheet
Question Number | Answer Key |
---|---|
1 | D |
2 | A |
3 | B |
4 | A |
5 | B |
6 | C |
7 | D |
8 | A |
9 | B |
10 | C |
11 | D |
12 | D |
13 | C |
14 | A |
15 | B |
16 | C |
17 | D |
18 | A |
19 | B |
20 | C |
21 | D |
22 | A |
23 | B |
24 | C |
25 | D |
To Continue Learning Please Login
Login with Google