Question: What would be wrong with adding the following statement to Figure 7.24s main method? PennyJar.addPenny(); Figure 7.24 /****** * Penny Jar Driver.java *Dean & Dean

What would be wrong with adding the following statement to Figure 7.24’s main method?

PennyJar.addPenny();

Figure 7.24

/****** * Penny Jar Driver.java *Dean & Dean * *This class drives the Penny Jar class. *** public class Penny

/****** * Penny Jar Driver.java *Dean & Dean * *This class drives the Penny Jar class. *** public class PennyJarDriver ( public static void main(String[] args) ( PennyJar penny Jarl = new PennyJar(); Penny Jar pennyJar2 = new PennyJar(); 2 3 PennyJar.setGoal (4000); pennyJarl.add Penny (); penny Jarl.addPenny(); pennyJar2.addPenny(); System.out.println(pennyJarl.getPennies ()); System.out.println(Penny Jar.getAll Pennies()); } // end main 3 // end class Penny Jar Driver Output: Clink! Clink! Clink! */

Step by Step Solution

3.32 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Because theres no static modifier addPenny is an insta... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Introduction To Programming With Java A Problem Solving Approach Questions!