A
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);
}
}
{
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);
}
}
- Correct Answer - Option(D)
- Views: 13
- Filed under category Java
- Hashtags:
Discusssion
Login to discuss.