public class Author 2 { 3 private String name; 4 private int numberOfAwards; 5 private boolean guildMember; 6 private String[] bestsellers; 7 8 public String Author() 9 { 10 name = "Grace Random"; 11...


public class Author
2 {
3 private String name;
4 private int numberOfAwards;
5 private boolean guildMember;
6 private String[] bestsellers;
7
8 public String Author()
9 {
10 name = "Grace Random";
11 numberOfAwards = 0;
12 guildMember = false;
13 bestsellers = {"Minority Report", "Ubik", "The Man in the High
Castle"};
14 }
15
16 public void setName(String n)
17 {
18 name = n;
19 }
20 public String getName()
21 {
22 return name;
23 }
24
25 public void winsAPulitzer()
26 {
27 System.out.println(name + " gave a wonderful speech!");
28 }
29 }


1. This class includes a constructor that begins on line 8; however, it contains an error. Describe the error.


2. Rewrite the constructor header on line 8 with the error identied in part c of this question corrected.


3. Demonstrate how you might overload the constructor for this class. Write only the header.


4. Write a line of Java code to create an instance (object) of this class. Name it someAuthor.


5. Write a line of code to demonstrate how you would use the someAuthor object created in question 4 to change the author's name to "Stephen King".


6. Write a line of Java code to call the winsAPulitzer method of the Author class using the someAuthor object created in question 10.



Jun 02, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here