018-001-001
Person Profile
Easy
Problem Description
In this problem, you will implement the displayInfo() method in the Person class that prints the person's profile including name, age, and hobby.
Create a Person class with name (String), age (int), and hobby (String) fields. Implement a constructor and displayInfo() method that prints the person's profile.
Test Cases
※ Output examples follow programming industry standards
Input:
new Person("Alice", 25, "Reading")Expected Output:
Person Profile: Name: Alice Age: 25 Hobby: Reading
Input:
new Person("Bob", 30, "Cooking")Expected Output:
Person Profile: Name: Bob Age: 30 Hobby: Cooking
Input:
new Person("Charlie", 18, "Gaming")Expected Output:
Person Profile: Name: Charlie Age: 18 Hobby: Gaming
Input:
new Person("Diana", 45, "Swimming")Expected Output:
Person Profile: Name: Diana Age: 45 Hobby: Swimming
❌ Some tests failed
Your Solution
Current Mode:● My Code
99
1
2
3
4
5
6
7
8
9
10
›
⌄
⌄
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here
sc.close();
}
}
0 B / 5 MB
You have 2 free executions remaining
