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

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter1: A First Program Using C#
Section: Chapter Questions
Problem 12RQ
icon
Related questions
Question

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

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,