Section C : 2013 Solved Theory
Question :11
A super class Perimeter has
been……………..not be written.
public
class Perimeter
{
double a,b;
Perimeter(double
aa,double bb)
{
a=aa;
b=bb;
}
double calculate()
{
return (2*(a+b));
}
void show()
{
System.out.println("Length
of a Parallelogram : "+a);
System.out.println("Bredth
of a Parallelogram : "+b);
System.out.println("Perimeter
of a Parallelogram : "+calculate());
}
}
public
class Area extends Perimeter
{
double h,area;
Area(double
ll,doublebb,doublehh)
{
super(ll,bb);
h=hh;
}
void doarea()
{
area=b*h;
}
void show()
{
System.out.println("Height
of a Parallelogram : "+h);
doarea();
super.show();
System.out.println("Area
of a Parallelogram : "+area);
}
}
Question : 12
A
doubly queue is……………………….not be written.
public
class Dequeue
{
intarr[]=new
int[100];
intlim,front,rear;
Dequeue(int
l)
{
lim=l;
front=rear=0;
}
void addfront(intval)
{
if(front==0)
{
System.out.println("Overflow
from front");
}
else
{
arr[--front]=val;
}
}
void addrear(intval)
{
if(rear==lim)
{
System.out.println("Overflow
from rear");
}
else
{
arr[rear++]=val;
}
}
intpopfront()
{
if(front==rear)
{
return (-9999);
}
else
{
return (arr[front++]);
}
}
intpoprear()
{
if(rear==front)
{
return (-9999);
}
else
{
return (arr[--rear]);
}
}
void show()
{
for(inti=0;i<lim;i++)
{
System.out.println((i+1)+"
= "+arr[i]);
}
}
No comments:
Post a Comment