Question 4
Consider the code given below that checks whether two laptops are the same. Method equals is overridden to compare two Laptop objects as follows: If two laptops have the same serial number, then they are the same. Based on the given information, answer the question that follows.
class Laptop{ private String sno;
//Constructor to initialize instance variable
public boolean equals(Object obj) { // CODE BLOCK }}public class Test { public static void main(String[] args) { Laptop l1 = new Laptop("A001"); Laptop l2 = new Laptop("A001"); if(l1.equals(l2)) System.out.println("l1 and l2 are the same"); else System.out.println("l1 and l2 are not same"); }}Choose the correct option to fill in place of CODE BLOCK so that the output is:
l1 and l2 are the same