Assume you have the following definition of class A: public class A{ private int x; private String s; public A(int a, St

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Assume you have the following definition of class A: public class A{ private int x; private String s; public A(int a, St

Post by answerhappygod »

Assume You Have The Following Definition Of Class A Public Class A Private Int X Private String S Public A Int A St 1
Assume You Have The Following Definition Of Class A Public Class A Private Int X Private String S Public A Int A St 1 (62.77 KiB) Viewed 31 times
Assume you have the following definition of class A: public class A{ private int x; private String s; public A(int a, String b) { x = a; s = b; } public boolean equals( Object o ) { if( o instanceof A) { A a = (A)o; return this.x == a.x && this.s } } else return false; } And the following fragment of code: String s1= "Hello"; A a1 = new A(10, s1); A a2 = new A(10, s1); A a3 = new A(20, s1); Which of the comparisons using equals is true? O a1.equals(a3) a1.equals(a2) None of the above == a.s; a2.equals(a3)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply