Question: Create the Author Class: Define a class named Author. The class should have attributes like name, email, and nationality. Implement a constructor to initialize these
Create the Author Class:
Define a class named Author.
The class should have attributes like name, email, and nationality.
Implement a constructor to initialize these attributes.
Provide getter methods to access the attributes.
Override the toString method to display the author's information.
Create the Book Class:
Define a class named Book.
The class should have attributes like title, price, and an Author object.
Implement a constructor to initialize these attributes, including the Author object.
Provide getter methods to access the attributes.
Override the toString method to display the book's information, including the associated author's
details.
Create the Main Class:
Define a class named Main that contains the main method.
Inside the main method:
Create an Author object.
Create a Book object using the Author object.
Print the details of the Book object, which should include the author's details.
Compile and Run:
Compile the Java files for the Author, Book, and Main classes.
Run the Main class to see the output.
When students run the Main class, they should see something like this:
Book: Harry Potter and the Philosopher's Stone, Price: $
Author: JK Rowling, Email:
jkrowling@example.com, Nationality: British
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
