Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Determine and explain the output from the following code: public class MyClass { public static void main(String args[]) { int [] a = new int

Determine and explain the output from the following code:

public class MyClass { public static void main(String args[]) { int [] a = new int [10]; int[] b = new int [10]; a [3] =7; b[3] =7; System.out.println(a.equals(b)); } }

I am getting a false output. Which I believe is incorrect and it should be true? I understand we are not using inheritance, but it seems that the code is placing the number 7 in the same place in both arrays, which should make it equal? Or must you have something like a=b in order for it to be equal?

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_2

Step: 3

blur-text-image_step3

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

Question

=+7. Are shareholders in a firm investors or gamblers?

Answered: 1 week ago