II B.Tech II Sem CSE Java Exercise - 6 a(Inheritance - Continued)

a)super keyword implementation

Aim:  Write a JAVA program give example for “super” keyword

Description:


Program:

(i)Using super to call super class constructor (Without parameters)

class A 
{
int l,b; 
A()
{
l=10;
b=20; 
}
}
class B extends A 
{
int h; 
B()
{
super();
h=30; 
}
int volume() 
{
return l*b*h; 
}
}
class superdemo 
{
public static void main(String args[]) 
{
B b1=new B();
int r=b1.volume(); 
System.out.println("The vol. is: "+r);
}
}
Output:



(ii)Using super to call super class constructor (With parameters)

class A 
{
int l,b;
A(int u,int v) 
{
l=u;
b=v; 
}
}
class B extends A 
{
int h;
B(int u,int v,int w) 
{
super(u,v);
h=w; 
}
int volume() 
{
return l*b*h; 
}
}
class superdemo1 
{
public static void main(String args[])
{
B b1=new B(30,20,30);
int r=b1.volume(); 
System.out.println("The vol. is: "+r);
    }
}

Output:





No comments

File Uploading in PHP

  File Uploading in PHP PHP allow you to upload any type of a file i.e. image, binary or text files.etc..,PHP has one in built global variab...