public class Author2 {3 private String name;4 private int numberOfAwards;5 private boolean guildMember;6 private String[] bestsellers;78 public String Author()9 {10 name = "Grace Random";11 numberOfAwards = 0;12 guildMember = false;13 bestsellers = {"Minority Report", "Ubik", "The Man in the HighCastle"};14 }1516 public void setName(String n)17 {18 name = n;19 }20 public String getName()21 {22 return name;23 }2425 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.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here