Given the following class definition, public class Pen {   private String name;   public Pen(String n)    {       name = n;   }      @Override    public String toString()    {         return this.name + "-";   } } public class Brush extends Pen {    private int ink;    public Brush(String n, int m)    {       super(n);         ink = m;    }    @Override   public String toString()   {         return super.toString() + this.ink + "-";   } } What is the output of the following program?       Brush fluffy = new Brush("Fluffy", 5);       System.out.print(fluffy); If there is no output, please specify "nothing" (no quotes) in the blank for the output.    No hand written and fast answer with explanation

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter10: Object-oriented Programming
Section: Chapter Questions
Problem 16RQ
icon
Related questions
Question

Given the following class definition,

public class Pen
{
  private String name;

  public Pen(String n)
   {
      name = n;
  }
  
  @Override
   public String toString()
   {
        return this.name + "-";
  }
}

public class Brush extends Pen
{
   private int ink;

   public Brush(String n, int m)
   {
      super(n);
        ink = m;
   }

   @Override
  public String toString()
  {
        return super.toString() + this.ink + "-";
  }
}

What is the output of the following program?

      Brush fluffy = new Brush("Fluffy", 5);
      System.out.print(fluffy);

If there is no output, please specify "nothing" (no quotes) in the blank for the output. 

 

No hand written and fast answer with explanation 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Developing computer interface
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
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage