007-001-005
Basic Class Creation: Product Information
Easy
Problem Description
Basic Class Creation: Product Information
In this problem, you will declare a Product class with a name field (String type) and a price field (int type).
Learning Objective: Understand basic class creation and field declaration
Overview
Create a Product class with name and price fields. Your class will be verified by automated tests.
Specifications
- Create a
Productclass - Declare a
namefield (String type) - Declare a
pricefield (int type) - Fields must be directly accessible from outside the class
Input
No input (automated tests will create Product objects and verify them)
Output Format
Test code creates Product objects, sets field values, and verifies output.
Example:
Product: Apple
Price: 150
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up