← Unit 3 · all exercises
Saved in this browser only

A book

Write a Book class storing a title and a page count. The constructor takes both. getTitle returns the title, and getPages returns the page count.

class Book { Book(String title, int pages); String getTitle(); int getPages(); }

Book.java
Loading editor…
Results

Examples

  • new Book("Dune", 412).getTitle() → Dune
  • new Book("Dune", 412).getPages() → 412

There are also 3 hidden tests you can't see. Solve the problem, not the examples.