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

+5
Answers (1)
  1. 24 February, 05:36
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers