Question: 1. Is it ok to compare two array references? For instance, suppose we have array x and array y, is it ok to do

1. Is it ok to compare two array references? For instance, supposewe have array x and array y, is it ok to do

1. Is it ok to compare two array references? For instance, suppose we have array x and array y, is it ok to do "if(x == y)"? Why or why not? (4 pts) 2. Consider the code below and answer questions (4 pts). int a[ ] = new int[10]; int b[] = new int[10]; for(int index = 0; index < 10; ++index) a[index] = b[index] = index; 2.1) True or False: all elements in array a have same values as elements in array b. 2.2) True or False: expression (x==y) returns true because these two arrays are equal. 3. (5pts) Given array x with declaration (int x[] = new int[100];), answer questions below: 3.1) how to access the value of the first array element? Write down your expression. 3.2) how to access the value of the last array element? Write down your expression. 3.3) how to print values of all array elements one by one? Write down your code. 4. (8pts) Consider the methods below and answer questions (each method is independent). public static XYZ(int a, int b) { return a+b; 4.1) 4.2) } Is this method correct or not? If not, how to make it right? 4.4) public static void ABC() { System.out.println("This is method ABC"); return 0; } Is this method correct or not? If not, how to make it right? 4.3) public static void WWW(int a, int b) { if(a > b) else System.out.println(a + "is bigger"); System.out.println(b + "is bigger"); } Is this method correct or not? If not, how to make it right? public static double calculateAREA(int x) { double pi = 3.14; double area = pi * x * x; return; } Is this method correct or not? If not, how to make it right?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

1 It is not okay to compare two array references using the equality operator This is because compare... View full answer

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 Programming Questions!