007-001-008

Creating Classes: Product Class

Medium

Problem Description

Creating Classes: Product class

In this problem, you will create a program that defines a Product class, instantiates it, assigns values to its fields, and displays the product information to standard output.

Learning Objective: Create classes and define fields (member variables)

Create a class to represent a product. Learn class definition and how to use fields.

Input

None

Output

Product Info:
Name: Laptop
Price: 89800

Specifications

  • Create Product class
  • Fields: String name, int price
  • Create instance in Main class, assign values to fields and display

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