Skip to content
Related Articles
Open in App
Not now

Related Articles

UGC-NET | NTA UGC NET 2019 June – II | Question 30

Improve Article
Save Article
  • Last Updated : 03 Dec, 2021
Improve Article
Save Article

What is the output of the following JAVA program?
public class Good{
Private int m;
Public Good(int m){this.m=m;}
public Boolean equals(Good n){return n.m=m;}
public static void main(String args [ ]){
Good m1=new Good(22);
Good m2=new Good(22);
Object S1=new Good(22);
Object S2=new good(22);
System.out.println(m1.equals(m2));
System.out.println(m1.equals(s2));
System.out.println(m1.equals(s2));
System.out.println(s1.equals(m2));
}
}
(A) True, True, False, False
(B) True, False, True, False
(C) True, True, False, True
(D) True, False, False, False
(E) None o the above.


Answer: (E)

Explanation: Note: Question is wrong. First change boolean to int data type then there is a possibility of option 4 is correct. So marks will be added to all students.

GeeksforGeeks code link: https://ide.geeksforgeeks.org/tWbTXjT2VA

Output:
true
false
false
false


Quiz of this Question
Please comment below if you find anything wrong in the above post

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!