Professional Documents
Culture Documents
Question no 1:
interface Shapes
{
int Number_of_line = 0;
String PenColor = null;
boolean Color_Fill =true;
void Draw();
}
class Circle implements Shapes
{
@Override
public void Draw()
{
System.out.println("The Circle is Drawn");
}
}
class Square implements Shapes
{
@Override
public void Draw()
{
System.out.println("The Square is Drawn");
}
}
class Triangle implements Shapes
{
@Override
public void Draw()
{
System.out.println("The Triangle is Drawn");
}
}
1|Page
SUBMITTED TO : Samia Raiz
SUBMITTED BY : DANISH EJAZ
REG NO : FA21-BSE-074
SECTION : BSE-3B
DEPERTMENT : COMPUTER SCIENCE
Question no 2:
interface Student
{
public abstract void take_exam();
}
class PhD_Students implements Student
{
public void take_exam()
{
System.out.println("I am PHD student and i give Defense Paper");
}
}
class Graduation_Students implements Student
{
public void take_exam()
{
System.out.println("I am Graduate Student and i give Written papers");
}
}
public class StudentAbstract
{
public static void main(String args [])
{
PhD_Students phS = new PhD_Students();
phS.take_exam();
Graduation_Students gS = new Graduation_Students();
gS.take_exam();
}
}
Question 3:
abstract class shapes
{
private String color;
private boolean filled ;
shapes()
2|Page
SUBMITTED TO : Samia Raiz
SUBMITTED BY : DANISH EJAZ
REG NO : FA21-BSE-074
SECTION : BSE-3B
DEPERTMENT : COMPUTER SCIENCE
{
this.color = "Red";
this.filled = true;
}
shapes(String c, boolean b)
{
this.color = c;
this.filled = b;
}
public void set_color()
{
this.color = "Orange";
}
public String get_color()
{
return this.color;
}
public void set_filling()
{
this.filled = true;
}
public boolean get_filling()
{
return this.filled;
}
{
double Area = (3.14)*this.radius*this.radius;
return Area;
}
public double get_Parameter()
{
double paremeter = 2 * (3.14) * this.radius;
return paremeter;
}
}
Question 4:
interface Animals
{
void sound();
void food();
}
abstract class Animals_Attributes
{
private String Color;
private String Type;
@Override
5|Page
SUBMITTED TO : Samia Raiz
SUBMITTED BY : DANISH EJAZ
REG NO : FA21-BSE-074
SECTION : BSE-3B
DEPERTMENT : COMPUTER SCIENCE
@Override
public void food()
{
System.out.println("The Food of Cat is milk");
}
@Override
public void sound()
{
System.out.println("The Sound of Dog is Boowuuwuw");
}
@Override
public void food()
{
System.out.println("The Food of Dog is Bone");
}
set_Color("white");
set_Type("Domestic");
System.out.println("The Color of Dog is = " + get_Color());
System.out.println("The Type of Dog is = " + get_Type());
System.out.println("====================================================");
}
}
class Tiger extends Animals_Attributes implements Animals
{
@Override
public void sound()
{
System.out.println("The Sound of Tiger is hakkkaaa");
}
@Override
public void food()
{
System.out.println("The Food of Tiger is Meat");
}
8|Page