Given the following code what is printed out public static v

Given the following code, what is printed out? public static void addOne(int[] A) {for (int i=0; i

Solution

the output is 2 3 4 5 6

explanantion: I WROTE THE BELOW FOR YOUR EXPLANATION

class Chegg
{
   public static void addOne(int[] A) //(3) (6)
   {
       for(int i=0;i<A.length;i++) //(4)
       A[i]++; // HERE WE ARE COPYING B ARRAY TO A ARRAY(5)
   }

   public static void main(String args[])
   {
       int[] B={1,2,3,4,5}; //we took a integer variable b of array type (1)
       addOne(B); //we are sending element to function called addOne(B) (2)
       for(int i=0;i<B.length;i++) //(7)
       System.out.print(B[i] +\" \"); /* WHILE PRINTING THIS STATEMENT WE WILL GET B ARRAY ELEMENT(8) */
   }
}

 Given the following code, what is printed out? public static void addOne(int[] A) {for (int i=0; iSolutionthe output is 2 3 4 5 6 explanantion: I WROTE THE BEL

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site