o T-Mobile 12:08 PM morgan.blackboard.com In-Class Exercise 10-6-17 Write a prog
ID: 3587595 • Letter: O
Question
o T-Mobile 12:08 PM morgan.blackboard.com In-Class Exercise 10-6-17 Write a program that creates a class named Employeeinfo that possesses four members (name, phone number, gender, and education level), creates the necessary public members functions and their definitions (including one constructor that accepts all four members as arguments and a destructor). Object instances should be created to store the values below into the five members, respectively for each employee: Employee"1: Jane Doe, SSS-1111, F, Ph.D. Employee 2: George Guy, 555-5555, M, Ed.D. Employee #3: Jack Smith, 555-0909, M. Masters Employee #4 : Sue Jones, SS5-3456, F, Bachelors Employee #5: Alex Adams, 5554001,M, Associates The program should output the name, phone number, gender, and education level of each employee Your output should resemble the following: Name of Employee #1: Jane Doe Phone Number of Employee #1: 555-1111 Gender of Employee #1: F Education Level of Employee #1: Ph.D Name of Employee #2: George Guy Phone Number of Employee #2: 555-5555 Gender of Employee #2: M Education Level of Employee #2: Ed.D Ne of Employee #3: Jack Smith Phone Number of Employee #3: 555-8989 Gender of Employee #3: M Education Level of Employee #3: Masters Name of Employee #4: Sue Jones Phone Number of Employee #4: 555-3456 Gender of Employee #6: F Education Level of Employee #4: Bachelors Name of Employee #5: Alex Adams Phone Number of Employee #5: 555-4801 Gender of Employee #5: M Education Level of Employee #5: AssociatesExplanation / Answer
Employeeinfo.java
//class creation
public class Employeeinfo
{
//varible decarations
public String name;
int phone;
String gender;
String Qualfication;
//class constructor defination
Employeeinfo(String ename,int ephone,String egneder,String Qual)
{
name=ename;
phone=ephone;
gender=egneder;
Qualfication=Qual;
}
//dispaly function for display employee details
public void display(int i)
{
System.out.println("----------------------------------");
System.out.println("Name of the Emploee #"+i+ " : "+name);
System.out.println("Phone Number of the Emploee #"+i+ " : "+phone);
System.out.println("Gender of the Emploee #"+i+ " : "+gender);
System.out.println("Qualification of the Emploee #"+i+ " : "+Qualfication);
System.out.println("----------------------------------");
}
//main funciton defination
public static void main(String []args)
{
//object1 creation
Employeeinfo ob1=new Employeeinfo("Ashok Kumar",999999999,"Male","PHD");
//object2 creation
Employeeinfo ob2=new Employeeinfo("Ashok",88888888,"Male","Mtech");
//object3 creation
Employeeinfo ob3=new Employeeinfo("Kumar",777777777,"Female","Btech");
//object3 creation
Employeeinfo ob4=new Employeeinfo("Rebba",666666666,"male","Btech");
//object3 creation
Employeeinfo ob5=new Employeeinfo("ram",55555555,"male","Btech");
//employee1 details display using display function call
ob1.display(1);
//employee2 details display using display function call
ob2.display(2);
//employee3 details display using display function call
ob3.display(3);
//employee4 details display using display function call
ob3.display(4);
//employee5 details display using display function call
ob3.display(5);
}
}
Output :
Note :
Java is a garbage collected language you cannot predict when (or even if) an object will be destroyed. Hence there is no direct equivalent of a destructor.
There is an inherited method called finalize, but this is called entirely at the discretion of the garbage collector.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.