Question 11
Consider the code given below.
class Rider implements Cloneable { String name; int[] distances; public Rider(String n, int[] d) { name = n; distances = d; } public Object clone() throws CloneNotSupportedException { return super.clone(); }}public class Test{ public static void main(String[] args) throws CloneNotSupportedException { int[] d = {50, 60, 70}; Rider r1 = new Rider("Raj", d); Rider r2 = (Rider) r1.clone(); Rider r3 = r1; r2.distances[1] = 90; r3.name = "Amit";
System.out.println(r1.name + " " + r1.distances[1]); System.out.println(r2.name + " " + r2.distances[1]); System.out.println(r3.name + " " + r3.distances[1]); }}What will the output be?