1. Engineering
  2. Computer Science
  3. 1 2 3...

Question: 1 2 3...

Question details

1.A parent class named Pen has a single constructor with a parameter of the Color data type. Pen has a public getter for the pen color named getColor. A child class name RedPen sets the color field of Pen to Color.RED in the constructor and has no getColor method. You instantiate RedPen, naming the object myPen. Write the complete statement that gets the color of myPen and stores it in a new Color object variable named penColor. Use proper spacing per the course style guide. Do not include additional spaces at the beginning or end.

2. You have a subclass named FancyPen that extends the superclass Pen. Both Pen and FancyPen havea public method named getFont which has no parameters and returns an object of the Font class. Fill in the blank to complete a method in FancyPen named getDefaultFont that passes the parent classs font value to the caller. public Font getDefaultFont) t3. A parent class named Pen has a single constructor with a parameter of the Color data type. You are extending the Pen class to include an int width field with a new class named VariableWidthPen Fill in the blank to complete the constructor for VariableWidthPen: public VariablewidthPen (Color color, int width) this.width - width; Use proper spacing per the course style guide. Do not include additional spaces at the beginning or end

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution