class Container { private int val1=1; private void printValue() { final int val2=2; class Containee{ public void f(){ System.out.println(String.format("Values are: %d and %d."),val1); } } } public static void main(String[] args) { (new Container()).printValue(); } } a.The above does not compile because the method f() requires an instance of class Container b.The above does not compile because the class definition in done within the body of the function c.The above code complies with no errors, but does not produce any ouput d.The above code does not compile because the methodf() cannot access the variable val1
class Container {
private int val1=1;
private void printValue()
{
final int val2=2;
class Containee{
public void f(){
System.out.println(String.format("Values are: %d and %d."),val1);
}
}
}
public static void main(String[] args) {
(new Container()).printValue();
}
}
a.The above does not compile because the method f() requires an instance of class Container
b.The above does not compile because the class definition in done within the body of the function
c.The above code complies with no errors, but does not produce any ouput
d.The above code does not compile because the methodf() cannot access the variable val1

It will not compile and will show an error
class Containee{
public void f(){
System.out.println(String.format("Values are: %d and %d."),val1);
}
}
because the class definition is done within the body of the function
-----
System.out.println(String.format("Values are: %d and %d."),val1);
above statement is incorrect as val2 is not passed
Step by step
Solved in 2 steps









