Question: Computer Science Short Question A. (3 points) Given the following code, what is the output? Assume a public number instance variable, and a equals() method

Computer Science Short Question

A. (3 points) Given the following code, what is the output? Assume a public number instance variable, and a equals() method that uses only this instance variable to check if two Bus objects values are semantically equal.

 Bus busA = new Bus(); Bus busB = new Bus(); busA.number = 44; busB.number = 44; System.out.println(busA == busB); System.out.println(busA.equals(busB)); Bus busC = busB; busB = busA; busA.number = 13; System.out.println(busA == busC); System.out.println(busA.equals(busC)); busC = busB; System.out.println(busA == busC); System.out.println(busA.equals(busC));

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!