0% found this document useful (0 votes)
4 views4 pages

Oops Pgms

Uploaded by

indua99018
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Oops Pgms

Uploaded by

indua99018
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1) Write a program to generate the resume.

Create 2 Java classes Teacher


(data: personal information, qualification, experience, achievements)
and Student (data: personal information, result, discipline) which
implements the java interface Resume with the method biodata().
interface Resume
{
void biodata();
}
class Teacher implements Resume
{
String name,qualification,achievements;
float experience;
public void biodata()
{
name="Imran Ulla Khan";
qualification="M.Tech";
achievements="Q1 publication";
experience=14.8f;
System.out.println("Teacher Resume");
System.out.println("Name : " +name);
System.out.println("Qualification : "+qualification);
System.out.println("Achievements : "+achievements);
System.out.println("Experience : "+experience);
}
}
class Student implements Resume
{
String name,discipline;
float result;
public void biodata()
{
name="Rahul Sharma";
result=9.8f;
discipline="Computer Science and Engineering";
System.out.println("");
System.out.println("Student Resume");
System.out.println("Name : " +name);
System.out.println("Result : "+result+" cgpa");
System.out.println("Discipline : "+discipline);
}
}
public class InterfaceP
{
public static void main(String[] args)
{
Teacher obj1=new Teacher();
obj1.biodata();
Student obj2=new Student();
obj2.biodata();
}
}

2) Design a super class called Staff with details as StaffId, Name, Phone,
Salary. Extend this class by writing three subclasses namely Teaching
(domain, publications), Technical (skills), and Contract (period). Write
a Java program to read and display at least 3 staff objects of all three
categories.
import java.util.Scanner;
class Staff
{
String staffId;
String name;
long phone;
float salary;
public void accept()
{
Scanner scanner = new Scanner(System.in);
System.out.print("Enter Staff Id: ");
staffId = scanner.next();
System.out.print("Enter Name: ");
name = scanner.next();
System.out.print("Enter Phone: ");
phone = scanner.nextLong();
System.out.print("Enter Salary: ");
salary = scanner.nextFloat();
}
public void display()
{
System.out.println("Staff Id: " + staffId);
System.out.println("Name: " + name);
System.out.println("Phone: " + phone);
System.out.println("Salary: " + salary);
}
}
class Teaching extends Staff
{
String domain;
int n;
public void accept()
{
super.accept();
Scanner scanner = new Scanner(System.in);
System.out.print("Enter Domain: ");
domain = scanner.next();
System.out.print("Enter Number of Publications: ");
n = scanner.nextInt();
System.out.println("\n");
}
public void display()
{
super.display();
System.out.println("Domain: " + domain);
System.out.println("Publications:"+n);
System.out.println("\n");
}
}
class Technical extends Staff
{
String skill;
public void accept()
{
super.accept();
Scanner scanner = new Scanner(System.in);
System.out.print("Enter technical Skills: ");
skill = scanner.nextLine();
System.out.println("\n");
}
public void display()
{
super.display();
System.out.println("Technical Skills: " + skill);
System.out.println("\n");
}
}
class Contract extends Staff
{
int period;
public void accept()
{
super.accept();
Scanner scanner = new Scanner(System.in);
System.out.print("Enter Period: ");
period = scanner.nextInt();
System.out.println("\n");
}
public void display()
{
super.display();
System.out.println("Contract Period: " + period);
}
}
class Four
{
public static void main(String[] args)
{
Teaching teaching = new Teaching();
System.out.println("Enter the details of Teaching Staff");
teaching.accept();

Technical technical = new Technical();


System.out.println("Enter the details of Technical Staff");
technical.accept();

Contract contract = new Contract();


System.out.println("Enter the details of Contract Staff");
contract.accept();
System.out.println("The details of Teaching Staff");
teaching.display();
System.out.println("The details of Technical Staff");
technical.display();
System.out.println("The details of Contract Staff");
contract.display();
}
}

You might also like