What will be the output of the program?


			  		

Loading

Practice Inner Classes –

What will be the output of the program?

public abstract class AbstractTest  {    
public int getNum() {
return 45;
}
public abstract class Bar {
public int getNum() {
return 38;
}
}
public static void main (String [] args) {
AbstractTest t = new AbstractTest() {
public int getNum() {
return 22;
};
AbstractTest.Bar f = t.new Bar() {
public int getNum() {
return 57;
}
};
System.out.println(f.getNum() + " " + t.getNum());
}
}

 

What will be the output of the program?


			  		

Loading

Practice Inner Classes –

What will be the output of the program?

public class TestObj {     
public static void main (String [] args) {
Object o = new Object() /* Line 5 */ {
public boolean equals(Object obj) {
return true;
}
} /* Line 11 */
System.out.println(o.equals("Fred"));
}
}

 

What will be the output of the program?


			  		

Loading

Practice Inner Classes –

What will be the output of the program?

public class HorseTest {     
public static void main (String [] args) {
class Horse {
public String name; /* Line 7 */
public Horse(String s) {
name = s;
}
} /* class Horse ends */
Object obj = new Horse("Zippo"); /* Line 13 */
Horse h = (Horse) obj; /* Line 14 */
System.out.println(h.name);
}
} /* class HorseTest ends */