Question: java is the language 1.) Given the arrays a and b, write a statement to create an array c of the same capacity as array

java is the language

1.) Given the arrays a and b,

write a statement to create an array c of the same capacity as array b

assuming that a and b are of the same length and are completely filled, write a statement to assign to c the corresponding 2*a+b . For example, if a[0]has 3 and b[0] has 4, then c[0] should have 10 (2*3+4).

2.) Provide the definition of a method named doThis that would take as input parameters two completely filled arrays of integers named a1 and a2. Your method should return back to the caller another integer array that holds the 2*a1+a2. For example, if a1[0] has 3 and a2[0] has 4, then the array that is returned should have 10 (2*3+4) at its location 0. Assume that the input arrays are of equal length.

Write a piece of code that would call pairwiseAdd and would pass as input to it the integer arrays x and y. Your code should save the returned array as z.

3.) Given the following definition of the class One:

class One {

private int x, y;

public A(int x, int y) { this.x = x; this.y = y;}

public A() {this.a = 1; this.b = 1;}

public int f( int a) {return a*x*y;}

}

provide the definition of the class B that is derived from class A such that it would have:

a private integer data member called z.

a constructor that would take three integers parameters called x, y and z. The first two parameters are to be used to initialize the base class data members and the third parameter is to be used to initialize z.

a default constructor that would use the previous constructor to set all data members to 1.

an overridden version of the function f that would return a*x*y*z using the base class version of the function.

an overloaded version of f that would take two integers parameters called mand n and would return a*x*y*z*m*n.

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!