/**
 * Anonymous Inner Classes
 */
public class Outer7 
{	
	public static void main(String[] args) 
	{
		Outer8 objOuter8 = new Outer8();
		objOuter8.act();
	}
	
	public void eat()
	{
		System.out.println("I am Eat Method");
	}
}

class Outer8 extends Outer7
{
	Outer7 objOuter7 = new Outer7(){
		public void eat()
		{
			System.out.println("I am Overridden Eat Method");
		}	
	};
	
	public void act()
	{
		objOuter7.eat();
	}
}

Output

I am Overridden Eat Method

Leave a reply