11
Loading subject content…
Loading subject content…
Loading practice questions…
What is the output of the following program?
public class Main {
public static void main(String[] args) {
int base = 10;
class Adder { int add(int x) { return base + x; } }
System.out.println(new Adder().add(5));
}
}What is the output of the following program?
class Main {
private int x = 7;
class Inner { int get() { return x; } }
public static void main(String[] args) {
Main o = new Main();
Main.Inner in = o.new Inner();
System.out.println(in.get());
}
}What is the output of the following program?
public class Main {
interface Greeter { String hi(); }
public static void main(String[] args) {
Greeter g = new Greeter() {
public String hi() { return "hello"; }
};
System.out.println(g.hi());
}
}