1.If you have defined a class, SavingsAccount, with a public static method, getNumberOfAccounts, and created a SavingsAccount object referenced by the variable account20, which of the following will call the getNumberOfAccounts method? |
|||||||||||||||||||||||||||||
|
SOL:
1) The correct answers are
a) account20.getNumberOfAccounts();
c) SavingsAccount.getNumberOfAccounts();
d) getNumberOfAccounts();
Explanation:
we can call static method in java without object refference
we can also call static method in java with object refference also
we can also call static method directly from class like in option c
2) The variables used by printStats method is
amount
option e is correct answer
Explanation:
we can not access non static variables name,quantity,inName,inQty from the static method printStats
Get Answers For Free
Most questions answered within 1 hours.