Question: Question 2 is based on code given below: class arrassignment { public static void main (String[] args) { int arr1[ ] = {34, 54, 90,
Question 2 is based on code given below: class arrassignment { public static void main (String[] args) { int arr1[ ] = {34, 54, 90, 45, 89, 42, 88, 22, 19, 49}; int arr2[ ] = {34, 54, 90, 45, 89, 42, 88, 22, 19, 49}; if (arr1 == arr2) System.out.
println("Same"); else System.out.println("Not same"); arr1 = new int[5]; System.out.println("arr1[4] is " + arr1[4]); System.out.println("arr2[4] is " + arr2[4]); } a) What will be the output for this code? Justify why is your output is in such a way. b) So how many ways are there to solve the issue on if(arr1==arr2)? Explain all the solutions. c) How many ways are there to copy an array from another array? Explain all the ways mentioned and justify your answers with examples
2. 2. Question 2 is based on code given below: class arrassignment public static void main (String[] args) int arrit 1 = 134, 54, 90, 45, 89, 42, 88, 22, 19, 49); int arr21 - {34, 54, 90, 45, 89, 42, 88, 22, 19, 49); if (arri = arr2) System.out.printin ("Same"); else System.out.println("Not same"); arrl - new int[5]; System.out.println("arri[4] is " + arri[4]); System.out.println("arr2[4] is " + arr2[4]); a) What will be the output for this code? Justify why is your output is in such a way. b) So how many ways are there to solve the issue on if (arri==arr2)? Explain all the solutions. c) How many ways are there to copy an array from another array? Explain all the ways mentioned and justify your answers with examples. (10 marks)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
