Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

4) Consider this code that creates some Location objects with coordinates x-10 a

ID: 3604780 • Letter: 4

Question

4) Consider this code that creates some Location objects with coordinates x-10 and y 20 Location a, b, c; a = new Location( 10,20) b = new Location( 10,20); After this code executes, what are the values of these bgolean expressions? a) a=- b) aequals(b) c) a=-u d) a equals(c) f) b.eguals(c) Also, explain the difference between = and the equals method for the Location class 5) Write a code fragment (in Java) that creates an array 50 integers, and initializes each cell to the same value as its index number (i.e. [0] = 0, [1] = 1, etc.)

Explanation / Answer

Question 4
Answer:
a) a== b will return false
b) a.equals(b) will return true
c) a==c will return false
d) a.equals(c) will return true
e) b == c will return true
f)b.equals(c) will return true

Question 5
Answer:
int a[] = new int[50];
for(int i=0;i<a.length; i++) {
a[i] = i;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote