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?
A. getNumberOfAccounts();
B. SavingsAccount.getNumberOfAccounts();
C. getNumberOfAccounts(account20);
D. None of the above, you cannot call a static method.

Respuesta :

Answer:

The correct answer to this question is "Option B".

Explanation:

In this question, it is defined that a class "SavingsAccount" declare is in this class a method that is "getNumberOfAccounts()" is defined, which created a class object reference variable "account20". The class uses a static method that is called by class name, and other options are wrong that can be described as follow:

  • In option A, It is not correct because it does not use the object.
  • In option C, It is wrong because it uses parameters.

ACCESS MORE