46.0k views
0 votes
Which of the following statements correctly instantiate the Rectangle object myRectangle? (i) myRectangle Rectangle = new Rectangle(10, 12); (ii) class Rectangle myRectangle = new Rectangle(10, 12); (iii) Rectangle myRectangle = new Rectangle(10, 12);

User Oparisy
by
4.9k points

1 Answer

1 vote

Answer:

The answer is "option iii" .

Explanation:

In the given question it is defined that a class "Rectangle" is defined in the class a parameter constructor is created that accepts two parameters. In this question, we create an instance of the class. In object creation first, we define class name then object name and use new keyword in the Instance of class and pass parameters.

  • In option i), An object name is used first and then class name. It is not correct.
  • In option ii), In instance creation of the class, we do not use class keyword that's why it is wrong.
User Eyonna
by
5.2k points