use of this and super keyword

PHOTO EMBED

Sun Apr 23 2023 05:39:06 GMT+0000 (Coordinated Universal Time)

Saved by @Shankar #instanceblocks #inheritance #overloading

 class Parent
{
	void m1()
		{
			System.out.println("Inside m1 Method - Parent");
		}
}
 class Child extends Parent
{
	void m1()
		{
			System.out.println("Inside m1 Method - Child");
		}
	void add(int a,float b)
		{
			System.out.println("Inside add Method");
			System.out.println(a+b);
			this.m1();
			super.m1();
		}
}
class Demo 
{
	public static void main(String[] args) 
	{
		//System.out.println("Hello World!");
		Child d = new Child();
		d.add(10,20.2f);	
	}
}
content_copyCOPY

super keyword call parent class var and members ---> super.m1();