007-004-004
Class Aggregation: Classes Containing Objects
Easy
Problem Description
Class Aggregation: Classes Containing Objects
Learning Objective: Understand aggregation where a class has another class object as a field
Overview
Create a Person class that has an Address class object. This demonstrates class aggregation (has-a relationship).
Specifications
- Address class: city field
- Person class: name field and address field of Address type
- Output Person information
Output Format
Name: Taro
City: Tokyo
Test Cases
※ Output examples follow programming industry standards
Input:
Expected Output:
Name: Taro City: Tokyo
❌ 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 9 free executions remaining
