Ask Question
7 March, 18:00

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).

+1
Answers (1)
  1. 7 March, 21:37
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers