indexOf() method of java.util.List class - Q 1
Program Code import java.util.*; class Product{ int id; String name; Product(int id, String name){ this.id=id; this.name=name; } } class Shop{ public static void main(String []args){ List<Product> lst=new ArrayList<>(); Product p1=new Product(10,"IceCream"); Product p2=new Product(11,"Chocolate"); lst.add(p1); lst.add(p2); System.out.println(lst.indexOf(p1)); } } Choices A. Compile Time Error B. 0 C. -1 D. 1 Correct Answer B