Assignment 1:

class demo{
void display()
{
System.out.println(“display”);
}
public int display1(int a,int b)
{
int c=a+b;
System.out.println(c);
return c;
}
public static void main(String args[])
{
demo f=new demo();
f.display();
f.display1(-2,5);
}
}

output:

display

7

Assignment 2a:

class school{
int mark;
private int salary;
static String school_name=”St.Antony’s Primary school”;
void conduct_exams(){
System.out.println(“nov 7”);
}
void publish_result(int mark)
{
System.out.println(mark);
}
}

Assignment 2b:

class teacher{
public static void main(String args[])
{
school e=new school();
e.conduct_exams();
e.publish_result(100);
}
}

output:

nov 7

100

Assignment 3a:

class Telephone{
int price=1500;
String name=”phone”;
public void call()
{
System.out.println(“calling facility”);
}
public void receive_call()
{
System.out.println(“receiving call facility”);
}
}

Assignment 3b:

class Mobile extends Telephone{
int price=15000;
String name=”Mobile”;
public void sms()
{
System.out.println(“messaging facility”);
}
public static void main(String args[])
{
Mobile samsung=new Mobile();
samsung.call();
samsung.receive_call();
Telephone BSNL=new Telephone();
System.out.println(“BSNL.price”);
System.out.println(“BSNL.name”);
}
}

output:

calling facility
receiving call facility
BSNL.price
BSNL.name


Leave a comment

Design a site like this with WordPress.com
Get started