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.
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
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.
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)