Compiler Complaints

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page

Answer:

No. The program will not compile.

Compiler Complaints

Here is what the compiler outputs for the mistaken program:

compiling: CheckingAccountTester.java

CheckingAccountTester.java:55: 
No method matching incrementUse() found in class CheckingAccount.
    bobsAccount.incrementUse();
                            ^
CheckingAccountTester.java:56: 
Variable useCount in class CheckingAccount not accessible from class CheckingAccountTester.
    bobsAccount.useCount = 15;
               ^
2 errors

The main() method cannot use the private variable useCount nor can it use the private method incrementUse(). These can only be used by the other methods of the object.

The main() method can use bobsAccount.processCheck() which is not private. It in turn uses the private method incrementUse(). This is OK.

QUESTION 10:

Does using private increase the security of Java programs for the Web?