A

Admin • 828.03K Points
Coach

Q. What is the output of the below Java program with a final local variable?

Code:
public class TestingMethods8
{
int cars = 20;
void change(final int cars)
{
cars = 10;
this.cars = cars;
}
public static void main(String[] args)
{
TestingMethods8 t8 = new TestingMethods8();
t8.change(30);
System.out.println(t8.cars);
}
}
  • (A) 30
  • (B) 20
  • (C) 10
  • (D) Compiler error
  • Correct Answer - Option(D)
  • Views: 13
  • Filed under category Java
  • Hashtags:

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.