Analyze the following code public class Test public static

Analyze the following code. public class Test { public static void main(String[] args) { int n = 2; xMethod(n); } public static void xMethod(uit n) { n++, System.out.println(\"n is\" + n); Return n; } } a. The code prints n is 1. b. The code prints n is 2. c. The code prints n is 3. d. The code has a syntax error because xMethod returns a value.

Solution

Ans)d

Reason:

the method xMethod signature we provided as void.But we are writing Return statement inside the method body which results syntax error.

__________Thank You

 Analyze the following code. public class Test { public static void main(String[] args) { int n = 2; xMethod(n); } public static void xMethod(uit n) { n++, Syst

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site