Question: Consider the following code: Collection playersnew ArrayList): // code to add elements to the collection here if (players.contains (name)) System.out.print (name + is one of

Consider the following code: Collection playersnew ArrayList): // code to add elements to the collection here if (players.contains (name)) System.out.print (name + "is one of the players in the collection."); Which answer best describes what will happen in this situation A. The method contains is not included in the Collection interface, therefore, this will not run. B. This will not run as is and in order, for it to run we need to make the if statement if (players.indexOf (name)8) C. The method contains is not included in the Collection interface but this will run because contains is a method in the ArrayList class. D. The code will run just fine as contains is included in the Collection interface and because of runtime polymorphism, the contains method in the ArrayList class will be executed
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
