Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions