011-003-004

Constructor: Calling Another Constructor with this

Medium

Problem Description

Constructor: Calling Another Constructor with this

Learning Objective: Understand calling another constructor in same class using this()

Implement multiple constructors in Product class and chain them with this().

Input

Line 1: Constructor type (default / name / full)
Default: No additional input
Name: Line 2 is product name
Full: Line 2 is name, Line 3 is price

Output

Product: [name], Price: [price]

Example

Input:

default
```java
Output:
```java
Product: Unknown, Price: 0

Test Cases

※ Output examples follow programming industry standards

Input:
default
Expected Output:
Product: Unknown, Price: 0
Input:
name
Laptop
Expected Output:
Product: Laptop, Price: 0
Input:
full
Phone
50000
Expected Output:
Product: Phone, Price: 50000
❌ Some tests failed
❌ エラー発生

Your Solution

Current Mode: My Code
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