5 years ago in Java Arrays

8.What is the output of the following program?

class MyMethod

{

static int func( int i)

{

return ++i;

}

public static void main(String[] args)

{

int i=0;

int j=func(i++) + i + func(++i);

System.out.println(i);

System.out.println(j);

}

}

[A] 5 2
[B] 2 5
[C] 2 6
[D] 2 4
Loading...
Next Question

Overall Stats

Attempted 307
Correct 62
Incorrect 83
Viewed 162

Answers

Guest
Guest
Vaibhav Bisht
Vaibhav Bisht - 3 weeks ago

Vaibhav Bisht from Dehradun, India is saying 2 6 is correct answer

Zo Go
Zo Go - 4 weeks ago

Zo Go from Casablanca, Morocco is saying 2 5 is correct answer

Awa Kone
Awa Kone - 4 weeks ago

Awa Kone from Berrechid, Morocco is saying 5 2 is correct answer

ayoub benigmim
ayoub benigmim - 1 month ago

ayoub benigmim from Casablanca, Morocco is saying 2 5 is correct answer

AHMED SOULIMANI
AHMED SOULIMANI - 1 month ago

AHMED SOULIMANI from Casablanca, Morocco is saying 5 2 is correct answer

Related Questions

Which one of the following will declare an array and initialize it with five numbers?

  • [A] Array a = new Array(5);
  • [B] int [] a = {23,22,21,20,19};
  • [C] int a [] = new int[5];
  • [D] int [5] array;