Westonci.ca makes finding answers easy, with a community of experts ready to provide you with the information you seek. Ask your questions and receive accurate answers from professionals with extensive experience in various fields on our platform. Experience the ease of finding precise answers to your questions from a knowledgeable community of experts.

What is the output of the following code? Assume the Rectangle class exists and all the methods called below exist and work as expected.

ArrayList blah = new ArrayList ();
blah.add( new Rectangle(3,5) );
blah.add( new Rectangle(2,15) );
blah.add( new Rectangle(5,5) );
double x=0;

System.out.println(blah.size());
for(Rectangle s: blah) x+=s.area();
System.out.println(x);


Sagot :

tonb

Answer:

3

70.0

Explanation:

There will be 3 elements (Rectangle instances) in the list.

The sum of the areas x will contain 3*5 + 2*15 + 5*5 = 70 and will be printed as a double.

Thanks for stopping by. We strive to provide the best answers for all your questions. See you again soon. We appreciate your time. Please come back anytime for the latest information and answers to your questions. Thank you for visiting Westonci.ca, your go-to source for reliable answers. Come back soon for more expert insights.