Final answer:
To test different bag implementations with a single test program, polymorphism is used by creating a common interface for different bag types and instantiating the desired implementation based on user input.
Step-by-step explanation:
In object-oriented programming, to have a single test program with one set of method calls capable of testing either an array-based or link-based bag implementation, you would use the feature known as polymorphism. This allows you to write code that can operate on objects of multiple types that share a common interface. For instance, you can define an interface Bag that specifies all the methods that any bag should have, such as addItem, removeItem, etc. Both your array-based and linked-list-based bags can implement this interface. In your test program, you declare your variable to be of type Bag. Then, based on the user's choice, you can instantiate this variable as either an instance of the array implementation or the linked list implementation. As a result, regardless of the user's choice, the interface's methods are called, and polymorphism ensures that the specific implementation's methods are executed.