- 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 III
Q 1 - What is the purpose of x character used in the conversionPattern of PatternLayout object?
B - Used to print the information stored in the MDC against the key.
D - Used to Left pad with spaces if the category name is less than 20 characters long.
Answer : A
Explanation
x − Used to output the NDC (nested diagnostic context) associated with the thread that generated the logging event.
Q 2 - What is the purpose of X character used in the conversionPattern of PatternLayout object?
B - Used to print the information stored in the MDC against the key.
D - Used to Left pad with spaces if the category name is less than 20 characters long.
Answer : B
Explanation
X − The X conversion character is followed by the key for the MDC. For example, X{clientIP} will print the information stored in the MDC against the key clientIP.
Q 3 - What is the purpose of % character used in the conversionPattern of PatternLayout object?
B - Used to print the information stored in the MDC against the key.
D - Used to Left pad with spaces if the category name is less than 20 characters long.
Answer : C
Explanation
% − The literal percent sign. %% will print a % sign.
Q 4 - What is the intent of %20c format modifier?
A - Left pad with spaces if the category name is less than 20 characters long.
B - Right pad with spaces if the category name is less than 20 characters long.
C - Truncate from the beginning if the category name is longer than 20 characters.
Answer : A
Explanation
%20c − Left pad with spaces if the category name is less than 20 characters long.
Q 5 - What is the intent of %-20c format modifier?
A - Left pad with spaces if the category name is less than 20 characters long.
B - Right pad with spaces if the category name is less than 20 characters long.
C - Truncate from the beginning if the category name is longer than 20 characters.
Answer : B
Explanation
%-20c − Right pad with spaces if the category name is less than 20 characters long.
Q 6 - What is the intent of %.20c format modifier?
A - Left pad with spaces if the category name is less than 20 characters long.
B - Right pad with spaces if the category name is less than 20 characters long.
C - Truncate from the beginning if the category name is longer than 20 characters.
Answer : C
Explanation
%.20c − Truncate from the beginning if the category name is longer than 20 characters.
Q 7 - What is the intent of %20.30c format modifier?
C - Truncate from the beginning if the category name is longer than 20 characters.
Answer : A
Explanation
%20.30c − Left pad with spaces if the category name is shorter than 20 characters. However, if the category name is longer than 30 characters, then truncate from the beginning.
Q 8 - What is the intent of %-20.30c format modifier?
C - Truncate from the beginning if the category name is longer than 20 characters.
Answer : B
Explanation
%-20.30c − Right pad with spaces if the category name is shorter than 20 characters. However, if the category name is longer than 30 characters, then truncate from the beginning.
Q 9 - Which of the following is correct about org.apache.log4j.HTMLLayout class?
Answer : C
Explanation
Both of the above options are correct.
Q 10 - Which of the following is correct about org.apache.log4j.HTMLLayout class?
B - It provides the name of the thread that invoked the logging request.
C - It provides the level associated with this logging request.
Answer : D
Explanation
All of the above options are correct.
Q 11 - Which of the following set the content type of html generated using HTMLLayout?
A - HTMLLayout.setContentType(String)
B - HTMLLayout.setLocationInfo(String)
Answer : A
Explanation
HTMLLayout.setContentType(String) − Sets the content type of the HTML content. Default is text/html.
Q 12 - Which of the following set the location information for the logging event using HTMLLayout?
A - HTMLLayout.setContentType(String)
B - HTMLLayout.setLocationInfo(String)
Answer : B
Explanation
HTMLLayout.setLocationInfo(String) − Sets the location information for the logging event. Default is false.
Q 13 - Which of the following set title for the HTML file using HTMLLayout?
A - HTMLLayout.setContentType(String)
B - HTMLLayout.setLocationInfo(String)
Answer : C
Explanation
HTMLLayout.setTitle(String) − Sets the title for the HTML file. Default is log4j Log Messages.
Q 14 - What is the purpose of immediateFlush configuration of FileAppender?
A - output stream to the file being flushed with each append operation.
B - to set the platform-specific encoding scheme.
Answer : A
Explanation
immediateFlush − This flag is by default set to true, which means the output stream to the file being flushed with each append operation.
Q 15 - What is the purpose of encoding configuration of FileAppender?
A - output stream to the file being flushed with each append operation.
B - to set the platform-specific encoding scheme.
Answer : B
Explanation
encoding − It is possible to use any character-encoding. By default, it is the platform-specific encoding scheme.
Q 16 - What is the purpose of threshold configuration of FileAppender?
A - output stream to the file being flushed with each append operation.
B - to set the platform-specific encoding scheme.
Answer : C
Explanation
threshold − The threshold level for this appender.
Q 17 - What is the purpose of Filename configuration of FileAppender?
A - output stream to the file being flushed with each append operation.
B - to set the platform-specific encoding scheme.
Answer : D
Explanation
Filename − The name of the log file.
Q 18 - What is the purpose of fileAppend configuration of FileAppender?
A - logging information to be appended to the end of the same file.
Answer : A
Explanation
fileAppend − This is by default set to true, which means the logging information being appended to the end of the same file.
Q 19 - What is the purpose of bufferedIO configuration of FileAppender?
A - logging information to be appended to the end of the same file.
Answer : B
Explanation
bufferedIO − This flag indicates whether we need buffered writing enabled. By default, it is set to false.
Q 20 - What is the purpose of bufferSize configuration of FileAppender?
A - logging information to be appended to the end of the same file.
Answer : C
Explanation
bufferSize − If buffered I/O is enabled, it indicates the buffer size. By default, it is set to 8kb.
Q 21 - What is the purpose of maxFileSize configuration of RollingFileAppender?
A - to set the critical size of the file above which the file will be rolled.
Answer : A
Explanation
maxFileSize − This is the critical size of the file above which the file will be rolled.
Q 22 - What is the purpose of maxFileSize configuration of RollingFileAppender?
A - to set the critical size of the file above which the file will be rolled.
Answer : A
Explanation
maxFileSize − This is the critical size of the file above which the file will be rolled.
Q 23 - What is the purpose of maxBackupIndex configuration of RollingFileAppender?
A - to set the critical size of the file above which the file will be rolled.
Answer : B
Explanation
maxBackupIndex − This property denotes the number of backup files to be created.
Q 24 - What is the purpose of DatePattern configuration of DailyRollingFileAppender?
A - to set the critical size of the file above which the file will be rolled.
B - to set the number of backup files to be created.
Answer : C
Explanation
DatePattern − This indicates when to roll over the file and the naming convention to be followed. By default, roll over is performed at midnight each day.
Q 25 - Which of the following DatePattern configuration of DailyRollingFileAppender rolls over the logs at the end of each month and at the beginning of the next month?
Answer : A
Explanation
'.' yyyy-MM − Roll over at the end of each month and at the beginning of the next month.
Answer Sheet
Question Number | Answer Key |
---|---|
1 | A |
2 | B |
3 | C |
4 | A |
5 | B |
6 | C |
7 | A |
8 | B |
9 | C |
10 | D |
11 | A |
12 | B |
13 | C |
14 | A |
15 | B |
16 | C |
17 | D |
18 | A |
19 | B |
20 | C |
21 | A |
22 | A |
23 | B |
24 | C |
25 | A |
To Continue Learning Please Login
Login with Google