The Gateway to Computer Science Excellence
+1 vote
112 views

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(s1.equals(s2));
        System.out.println(m1.equals(s2));
        System.out.println(s1.equals(m2));
    }
}
  1. True, True, False, False
  2. True, False, True, False
  3. True, True, False, True
  4. True, False, False, False
in Java by Veteran (425k points)
edited by | 112 views

1 Answer

0 votes
marks given to all
by (29 points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,644 questions
56,523 answers
195,608 comments
101,286 users