What will be the output of the program? public class TestObj { public static…

PYQ Hexaware Hiring Assessment 2023

What will be the output of the program?

public class TestObj
{
public static void main (String [] args)
{
Object o = new Object() /* Line 5 */
{
public boolean equals(Object obj)
{
return true;
}
} /* Line 11 */
System.out.println(o.equals("Fred"));
}
}
  1. A.

    It prints "true".

  2. B.

    It prints "Fred".

  3. C.

    An exception occurs at runtime.

  4. D.

    Compilation fails

Attempted by 186 students.

Sign up free to check your answer

Sign up free

Explore the full course: Cdac C Cat Complete Preparation

Loading lesson…