Question: What will be the result of compiling and running the following program? Select the one correct answer. (a) The code will fail to compile, since
What will be the result of compiling and running the following program?
![public class Passing { public static void main (String[] args) { int](https://dsd5zvtm8ll6.cloudfront.net/images/question_images/1706/8/7/7/63365bce2c1e67c41706877633693.jpg)
Select the one correct answer.
(a) The code will fail to compile, since x[0]++; is not a legal statement.
(b) The code will compile and will print a=1 b=1 bArr[0]=1 at runtime.
(c) The code will compile and will print a=0 b=1 bArr[0]=1 at runtime.
(d) The code will compile and will print a=0 b=0 bArr[0]=1 at runtime.
(e) The code will compile and will print a=0 b=0 bArr[0]=0 at runtime.
public class Passing { public static void main (String[] args) { int a = 0; int b= 0; int [] bArr= new int [1]; bArr [0] inc1(a); inc2 (bArr); } } = b; System.out.println ("a=" + a + " b=" + b + "bArr [0]=" +bArr [0]); public static void incl (int x) { x++; } public static void inc2 (int [] x) { x[0] ++; }
Step by Step Solution
3.46 Rating (146 Votes )
There are 3 Steps involved in it
d The variables a and b are local variables that contain primitive values ... View full answer
Get step-by-step solutions from verified subject matter experts
