Question 6
Consider the code given below that checks whether two players are the same. Method equals is overridden to compare two Player objects as follows.
If two players have the same playerID and teamName, then they are said to be equal.
class Player { private String playerID; private String teamName;
// Constructor to initialize instance variables
public boolean equals(Object obj) { //CODE BLOCK }}public class Test { public static void main(String[] args) { Player p1 = new Player("004", "Red"); Player p2 = new Car("004", "Red"); if (p1.equals(p2)) System.out.println("p1 and p2 are same"); else System.out.println("p1 and p2 are different"); }}Choose the correct option to fill in place of CODE BLOCK so that the output is:
p1 and p2 are same