Question: In a certain style of object - oriented programming an object's methods aren't called directly. Instead, they must be invoked indirectly by calling a dispatch
In a certain style of objectoriented programming an object's methods aren't called directly. Instead, they must be invoked indirectly by calling a dispatch method that every object inherits from a toplevel Dispatcher class. This style allows us to control when and how methods are invoked. For example, assume savings is an instance of an Account class with deposit and withdraw methods. This is how clients would invoke these methods:
savings.dispatch
The dispatch method is implemented in the Dispatcher superclass: Dispatcher.java.
Complete the implementation of the dispatch method using reflection and test it using Bank.java.
Hints:
The parameter Object args is called a varargs parameter in Java. It means the user can give any number of inputs and these will be automatically lumped together as a single array of objects called args.
A class may have several methods with the same name overloading They are distinguished by the number and types of their parameters. So you will need to create a second array called argTypes that contains the types of the objects in args. Ie for full credit don't assume args contains one argument of type Double.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
