Write statements needed to do the following in order one


Q1/ What are the problems in the following design of class A:

class A{

int x;

public void setX(int d){x=d+5; d++;}

public int getX(){return x;}

public void printX(){System.out.println("x = "+x);}

}

Q2/ Write statements needed to do the following in order; one statement is needed for each point:

  1. Creating an array of 5 integers that are all initialized to 1's
  2. Modify the second element of your array (the array you created in part 1) to 8
  3. Print the last element of your array (the array you created in part 1)
  4. Creating an array list of boolean values

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Write statements needed to do the following in order one
Reference No:- TGS02748016

Now Priced at $10 (50% Discount)

Recommended (94%)

Rated (4.6/5)