Ask Question
30 March, 08:36

A base class named Garden contains a private field width and a property public int Width that contains get and set accessors. A child class named VegetableGarden 359360does not contain aWidth property. When you write a class in which you declare an object as follows, what statement can you use to access the VegetableGarden's width? VegetableGarden myGarden = new VegetableGarden ();

a. myGarden. Width

b. myGarden. base. Width

c. VegetableGarden. Width

d. You cannot use Width with a VegetableGarden object.

+5
Answers (1)
  1. 30 March, 11:40
    0
    a. myGarden. Width

    Explanation:

    Given: A base class named Garden contains a private field width and a property public int Width that contains get and set accessors. A child class named VegetableGarden does not contain a Width property. So the structure is as follows:

    class Garden{

    private int width;

    public int Width;

    }

    class VegetableGarden extends Garden{

    }

    In the client class, we create an instance of VegetableGarden as follows:

    VegetableGarden myGarden = new VegetableGarden ();

    From this instance the Width field can be accessed using the following mechanism:

    myGarden. Width
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “A base class named Garden contains a private field width and a property public int Width that contains get and set accessors. A child 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