Question: Java The output: result = 1001 Can you explian me the following code? public class ObjComp { public static void main(String[] args) { int result

Java

The output: result = 1001

Can you explian me the following code?

public class ObjComp {

public static void main(String[] args) {

int result = 0;

ObjComp oc = new ObjComp();

Object o = oc;

if (o == oc) {

result = 1;

}

if (o != oc) {

result = result + 10;

}

if (o.equals(oc)) {

result = result + 100;

}

if (oc.equals(o)) {

result = result + 1000;

}

System.out.println("result = " + result);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!