Question: Hi I am taking a java class and I was given this problem can anyone please help? 1. Write a main function with the following
Hi I am taking a java class and I was given this problem can anyone please help?
1. Write a main function with the following code, execute it, observe the output and explain what is the reason for observing such output?
int [] a, b;
a = new int[10];
a[5] = 0;
b = a;
a[5] = 42;
System.out.println(b[5]);
2. Write a main function with the following code, execute it, observe the output and explain what is the reason for observing such output?
int[] a, b;
a = new int [10];
a[5] = 0;
b = a.clone();
a[5] = 42;
System.out.println(b[5]);
3. Explain the reason for the differences/similarities between outputs of programs (1) and (2) above.
4.
(A) Implement a Point class with x and y coordinates of type integer and setter and getter methods for x and y.
(B) Implement the clone method for Point class.
(C) Write a main method that creates an object of type Point and invokes its clone method.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
