Ask Question
28 December, 23:32

Java’s class Color has a constructor that takes three integers as parameters: the red, green, and blue components of the color. A class Balloon has two fields: double radius and Color color. Write a constructor for the Balloon class that takes no parameters and sets the balloon’s radius to 10 and its color to "sky blue" (with RGB values 135, 206, and 250).

+2
Answers (1)
  1. 29 December, 03:17
    0
    public Balloon () {

    //Invokes the 2 argument constructor for balloon with relevant

    //parameters

    this (10, new Color (135,206,250));

    }

    Explanation:

    class Balloon{

    //Private fields in the Balloon class

    private double radius = 0;

    private Color c = null;

    / / Constructor with two arguments - radius and Color

    public Balloon (double radius, Color c) {

    this. radius = radius;

    this. c = c;

    }

    / / No argument constructor

    public Balloon () {

    //Invokes the 2 argument constructor for balloon with relevant

    //parameters

    this (10, new Color (135,206,250));

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Java’s class Color has a constructor that takes three integers as parameters: the red, green, and blue components of the color. A class ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers