Question: JAVA thanks in advance, 1.) Provide the copy constructor for the following class public class X{ int [] r; public X(int[] r){ this.r = new

JAVA

thanks in advance,

1.) Provide the copy constructor for the following class

public class X{

int [] r;

public X(int[] r){

this.r = new int[r.length];

for (int i = 0; i

this.r[i] = r[i];

}

}

2.) Given the following class definition

public class X{

int r, c

public X(int r, int c){

this.r = r;

this.c = c;

}

}

Write a piece of code that would create an array of 10 such objects namedxArray. Each element of the array should be initialized with 10 and 20 for rand c respectively.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!