The Essay class has a default constructor, a constructor with two parameters, and a constructor with three parameters. Declare the following objects: essay1 with no arguments essay2 with essayTitle and essayAuthor as arguments essay3 with essayTitle, essayAuthor, and essayYear as arguments Ex: If the input is Painting Cole 1919, then the output is:   Essay: Undefined, Unspecified, 0 Essay: Painting, Cole, 0 Essay: Painting, Cole, 1919 Archive.java      public class Archive { publicstaticvoidmain(String[] args) { Scannerscnr=newScanner(System.in); StringessayTitle; StringessayAuthor; intessayYear;   essayTitle=scnr.next(); essayAuthor=scnr.next(); essayYear=scnr.nextInt();   /* Your code goes here */   essay1.print(); essay2.print(); essay3.print(); } } Essay.java public class Essay {   private String title;   private String author;   private int year;      public Essay() { // Default constructor      title = "Undefined";      author = "Unspecified";      year = 0;   }      public Essay(String essayTitle, String essayAuthor) {      title = essayTitle;      author = essayAuthor;      year = 0;   }      public Essay(String essayTitle, String essayAuthor, int essayYear) {      title = essayTitle;      author = essayAuthor;      year = essayYear;   }      public void print() {      System.out.println("Essay: " + title + ", " + author + ", " + year);   }}

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 2PE
icon
Related questions
Question

The Essay class has a default constructor, a constructor with two parameters, and a constructor with three parameters. Declare the following objects:

  • essay1 with no arguments
  • essay2 with essayTitle and essayAuthor as arguments
  • essay3 with essayTitle, essayAuthor, and essayYear as arguments
Ex: If the input is Painting Cole 1919, then the output is:

 

Essay: Undefined, Unspecified, 0 Essay: Painting, Cole, 0 Essay: Painting, Cole, 1919

Archive.java 
 
 
public class Archive {
publicstaticvoidmain(String[] args) {
Scannerscnr=newScanner(System.in);
StringessayTitle;
StringessayAuthor;
intessayYear;
 
essayTitle=scnr.next();
essayAuthor=scnr.next();
essayYear=scnr.nextInt();
 
/* Your code goes here */
 
essay1.print();
essay2.print();
essay3.print();
}
}
Essay.java
public class Essay {
   private String title;
   private String author;
   private int year;
   
   public Essay() { // Default constructor
      title = "Undefined";
      author = "Unspecified";
      year = 0;
   }
   
   public Essay(String essayTitle, String essayAuthor) {
      title = essayTitle;
      author = essayAuthor;
      year = 0;
   }
   
   public Essay(String essayTitle, String essayAuthor, int essayYear) {
      title = essayTitle;
      author = essayAuthor;
      year = essayYear;
   }
   
   public void print() {
      System.out.println("Essay: " + title + ", " + author + ", " + year);
   }
}
 
 
 
AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Knowledge Booster
Data members
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,