007-001-011

Class Creation: With Method

Easy

Problem Description

class Creation: With method

In this problem, you will create a Book class with title and price fields and a showInfo() method that outputs their values to standard output.

Learning Objective: Create a class with fields and methods

Overview

Create a class with a method that outputs field values.

Specifications

  • Create a Book class
  • Define a String field title
  • Define an int field price
  • Create showInfo() method to output information in this format:
    • Title: <title value>
    • Price: <price value>

Output Format

The showInfo() method outputs 2 lines:

Title: <title>
Price: <price>

Testing

Automated tests will set various values and verify the method behavior.

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