Q BgQuestion:

      
Pupil
Karma Points: 50
Respect (83%):
posted by  Al3x 84 on 11/4/2009 10:54:15 PM  |  status: Closed  |  Earned Karma: 50

Java class

Course Textbook Chapter Problem Needs by
N/A N/A N/A N/A 11/5/2009 at 4:00:00 PM
Question Details:
 

Consider the following (partially defined) Java class Book.

 public class Book {

private String author;

private String title;

private int year;

private String publisher;

 public Book (String a, String t, int y, String p) {

// ... code

} public Book() {

 // ... code

} public String toString() {

 // ... code

} public void displayBook() {

 // ... code }

}

a. List the data fields (also known as properties or instance variables) of the class Book.

b. How many constructors define the class Book.

c. Identify an overloaded entity defined by the class Book. Explain.

d. List the methods defined by the class Book.

Bonus Point Alert! Earn +7 additional karma points for helping this gold member.

AAnswers:

Answer Question Ask for clarification
Oracle
Karma Points: 23,191
posted by Marth on 11/4/2009 11:49:43 PM  |  status: Live
Asker's Rating: Lifesaver   
Response Details:
a.

private String author;
private String title;
private int year;
private String publisher;

b.
Constructors are methods with the same name as the class and no return type.  They are listed below:

public Book (String a, String t, int y, String p);
public Book();

c.
The constructor is technically overloaded because there are two constructors with the same name but with different parameters, creating different method signatures.

d.
Besides the two constructors, there are two additional methods:

public String toString();
public void displayBook();


Thank you for rating my response. Feel free to PM me if you have further questions.

"Judging by the pollution content of the atmosphere, I believe we have arrived at the late twentieth century." - Spock, The Voyage Home

"Computer, compute to the last digit the value of pi" - Spock, Wolf in the Fold

"Lois Lane is falling, accelerating at an initial rate of 32ft per second per second. Superman swoops down to save her by reaching out two arms of steel. Ms. Lane, who is now traveling at approximately 120 miles per hour, hits them, and is immediately sliced into three equal pieces." - Sheldon Cooper, Big Bang Theory
Answer Question Ask for clarificarion

Join Cramster's Community

Cramster.com brings together students, educators and subject enthusiasts in an online study community. With around-the-clock expert help and a community of over 100,000 knowledgeable members, you can find the help you need, whenever you need it. Join for free today » How Cramster is different from tutoring »