You are on page 1of 2

MITRAJSINH 170410107013

TY CE 1 Batch : A

Assignment 3
Aim: Write a program to demonstrate use of this, super and final keyword.

class A
{
int a;
final int b= 3;
A(int a)
{
this.a=a;
}
void show()
{
System.out.println("a="+a);
System.out.println("b="+b);
}
final void display()
{
System.out.print("hello");
}
int mul()
{
return (a*b);
}
}

class B extends A
{
int c, d;
B(int p, int r)
{
super(p);
d=r;
}
void show()
{
c=d*mul();
super.show();
System.out.println("c="+c);
}
}

class Athree
{
public static void main(String args[])
MITRAJSINH 170410107013
TY CE 1 Batch : A

{
System.out.println("\n");
B b1 = new B(1,2);
b1.show();
b1.display();
}
}

Output:

You might also like