Question: In the Bag class, we created a static global variable called designer and created static getters and setters for it. What if we made these

In the Bag class, we created a static global variable called designer and created static getters and setters for it. What if we made these methods nonstatic instead?

a. Remove the static keyword from getDesigner() and setDesigner(). Now they are instance methods. 

b. In the BagStore.java code, try calling the getDesigner() method from the blueBackpack and the pinkPurse objects. What happens? 

c. Use the setter method to reassign a new value to the designer variable. Call the setter from blueBackpack. Afterwards, print the value of designer using the getter from blueBackpack and pinkPurse objects. What happens and why?  

Step by Step Solution

3.48 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The difference between static and nonstatic methods in Java stems from the fact that static methods belong to the class itself while nonstatic instanc... 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 Java Program Questions!