Question
Q1. Assume you have written a class called 'Fan' with a constructor that has one parameter for the radius of the fan. You want to
Q1. Assume you have written a class called 'Fan' with a constructor that has one parameter for the radius of the fan. You want to instantiate an array of five fans with radii of 5, 6, 7, 8, and 9. Fill in the blank to complete the following code to make this so:
Fan[] fans = new Fan[5]; for (int i = 0; i < 5; i++) { _____________________; }
Q2. Assume you have written a class named 'Fan' with a primitive integer private field (instance variable) named 'radius'. You intend to allow other classes in other packages to make Fan objects. Fill in the blank to complete the constructor header for a Fan constructor below that sets the radius field with the proper parameter.
________________________ { this.radius = radius; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started