017-003-004
Default and Static Methods: Logging Feature
Hard
Problem Description
Default and static Methods: Logging Feature
In this problem, you will create a program that defines default and static methods in a Logger interface, reads a log level and message from standard input, and displays them in a formatted log entry to standard output.
Learning Objective: Understand interface default and static methods
Define default and static methods in Logger interface and use them in implementing class.
Input
Line 1: Log level (info or warn)
Line 2: Message
Output
[PREFIX] [level]: [message]
Timestamp: [current time]
```java
## Example
Input:
```java
info
System started
```java
Output:
```java
[LOG] INFO: System started
Timestamp: current
Test Cases
※ Output examples follow programming industry standards
Input:
info System started
Expected Output:
[LOG] INFO: System started Timestamp: current
Input:
warn Low memory
Expected Output:
[LOG] WARN: Low memory Timestamp: current
Input:
info Test
Expected Output:
[LOG] INFO: Test Timestamp: current
Input:
A hello
Expected Output:
[LOG] A: hello Timestamp: current
❌ Some tests failed
Your Solution
Current Mode:● My Code
Logger.java🔒
ConsoleLogger.java🔒
Main.java🔒
3/6 ファイル189B
⚠️警告
- No main method found
9
1
2
3
4
5
›
⌄
import java.util.Scanner;
interface Logger {
void log(String level, String message);
}
0 B / 5 MB
You have 2 free executions remaining
