go to previous page   go to home page   go to next page

Answer:

No. The program will not compile.


Compiler Complaints

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.

Here is what the compiler outputs for the mistaken program:

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


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

QUESTION 10:

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