007-001-009
Class Definition: Book Management
Easy
Problem Description
Class Definition: Book Management
Learning Objective: Understand the basic structure of a class (fields and methods)
Overview
Define a Book class to represent a book. Learn that classes have "fields that hold data" and "methods that define behavior".
Specifications
Book Class
- Fields:
String title(book title)String author(author name)int pages(number of pages)
- Methods:
void displayInfo(): Display book information in format "Title: [title], Author: [author], Pages: [pages]"
Main Class
- Create an instance of Book class (assign values directly to fields)
- Call displayInfo() method to display information
Output Format
Title: Clean Code, Author: Robert Martin, Pages: 464
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
