bw.getAvailable() returns 100, therefore when you pass -bw.getAvailable() to addMore, you are essentially passing -100 . addMore() performs 100+ (-100), which makes available = 0. That is why System.out.println(bw.getAvailable()); prints 0.
Well, this is a very basic programming question. bw is a variable and () can only be applied to a method name while invoking that method on a variable. For example, bw.addMore(0). So not sure why you think bw(0) makes sense? What do you think bw(0) means?
Looking at other questions that you have asked, I will suggest you to go through a good Java book to understand the basics before attempting mock exams. Otherwise, mock exams will not help you as much.
I see in this question the explanation "Bandwidth class does not have a no-args constructor so this will not compile." is given as the reason for "bw = new Bandwidth();" being incorrect.
Wouldn't Java create a default constructor in this example?
I looked further into the default constructor, it seems like I gained some understanding getting this wrong. I had understood that without a *no-args* constructor, a default would be created by the compiler. I know now that a default is only created if *no* constructor is given at all. This was also in the book:
"The compiler will complain that Account class does not have a constructor that takes no arguments. What happened to the default constructor, you ask? Well, since this class provides a constructor explicitly, the compiler feels no need to add one on its own."
Now that i'm further in the book, I see how unnecessary my asking this question was. The default constructor is discussed at length further along this version of the book. Thanks again, team.