Oracle
1Z0-850 · Question #54
You need to create a class Foo that will record the number of times the go() method is invoked on a particular instance of the class. Which solution correctly implements this goal?
The correct answer is A. Declare a local variable invokeCount inside the go() method, and increment the variable within the go() method. B. Declare an instance variable invokeCount for the class Foo, and increment the variable within the go() method. See the full explanation below for the reasoning.
Question
You need to create a class Foo that will record the number of times the go() method is invoked on a particular instance of the class. Which solution correctly implements this goal?
Options
- ADeclare a local variable invokeCount inside the go() method, and increment the variable within the go() method.
- BDeclare an instance variable invokeCount for the class Foo, and increment the variable within the go() method.
- CDeclare a static variable invokeCount for the class Foo, and increment the variable within the go() method.
- DDeclare a method parameter invokeCount as the argument to the go() method, and increment the variable within the go() method.
How the community answered
(67 responses)- A72% (48)
- C18% (12)
- D10% (7)
Community Discussion
No community discussion yet for this question.