014-008-001
Object Inheritance: equals() Override
Easy
Problem Description
Object inheritance: equals() override
In this problem, you will create a program that overrides the equals() method in a Product class to compare two product IDs and displays the comparison result to standard output.
Learning Objective: Understand all classes implicitly inherit from Object class and override equals()
Create Product class and override equals() method inherited from Object class. Implement custom logic to compare if two products are the same.
Input
Line 1: Product ID 1 (string)
Line 2: Product ID 2 (string)
Output
Product1: [ID1]
Product2: [ID2]
Equals: [true/false]
```java
## Examples
### Example 1: Same ID
Input:
```java
P001
P001
```java
Output:
```java
Product1: P001
Product2: P001
Equals: true
```java
### Example 2: Different IDs
Input:
```java
P001
P002
```java
Output:
```java
Product1: P001
Product2: P002
Equals: false
```java
### Example 3: Boundary (single character)
Input:
```java
A
A
```java
Output:
```java
Product1: A
Product2: A
Equals: true
Test Cases
※ Output examples follow programming industry standards
Normal case
Input:
ITEM100 ITEM100
Expected Output:
Product1: ITEM100 Product2: ITEM100 Equals: true
Normal case
Input:
X100 X200
Expected Output:
Product1: X100 Product2: X200 Equals: false
Your Solution
Current Mode:● My Code
Product.java🔒
Solution.java🔒
2/6 ファイル127B
9
1
2
›
⌄
public class Product {
}
0 B / 5 MB
You have 10 free executions remaining
