Question: Excercisr 4 in JAVA, adjusting class to count objects help Exercise 4 - Using Static Objects 1. Open and study class CountObjects.java. The main method



Exercise 4 - Using Static Objects 1. Open and study class CountObjects.java. The main method in this class creates a random number of objects of the class ClassC. However, variable numObjects has value -1, which you must change so that when this program is executed it prints the number of Class C objects created. 2. You can make changes to ClassC java and to CountObjects, java. However, the only changes that you can make to ClasC java are to the declaration of counter and changing the statement in the constructor of ClassC. Do not add more code to the constructor of ClassC. The only change that you can make in class CountObjects is the statement in line 9. numObjects = -1; you can assign to numObjects the number of objects that have been created 3. Run your code and make sure that the value that it prints is the number of objects created and not - 1 (the number of these objects should be 16. Note that you cannot simply write numObjects = 16 in class CountObjects). {egeuen jeyi jo Adoo juojelp e jou pue egeuen Jejunoo owes au seseojou pojejo s jeu pelqo Kone jeu ensue nok op MOH (qon suoo ay u juwelejs ey ebueyo nok pinoys moy 'os) pornoexe si joponnsuoo oyi jeyn awn Liene e qepjen jeul jo enjen eyi aseesu pojejo speqo jo jequnu ayjunoo on osseo u jaunoo ejqeuen sn jqoid ng gun jou o HMN 2. public class CountObjects { 3 40 public static void main(String[] args) { 5 int numobjects; 6 Class C = null; 7 for (int i = 0; i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
