MCQ Single Best Answer Not Set

QWhat will be the output after the following program is compiled and executed?
public class Test{
      public static void main(String args[]){
            int x = 10;
	    x = myMethod(x--);
	    System.out.print(x);
      }

      static int myMethod(final int x){
            return x--;
      }
}

ID: #2122 Declaration and Access Control in Java 548 views
Question Info
#2122Q ID
Not SetDifficulty
Declaration and Access Control in JavaTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A The will compile successfully and display 9 as output.
  • B The program will lead to compilation error.
  • C The program will lead to runtime error.
  • D The program will compile successfully and display 10 as output.
Correct Answer: Option B

Explanation

The program will lead to compilation error.

Share This Question

Challenge a friend or share with your study group.