First compile all the classes.But to run the program we have to run the class which is having the
main method.
here TestEveryOne.java class is having the main() method.If we run the program we may get the
output.
Before Posting the code I checked for Errors twice,Only After ensuring that this programs are
having no errors and working fine am posting.If Any Problem Happened just do comment.I will
be available until you satisfied with my answer. _Thank you
To Compile .java file we have to use javac command like to compile javac TestEveryOne.java
To run the program we have to use java TestEveryOne.
_____________________________________________________________________
TestEveryOne.java
public class TestEveryOne {
public static void main(String[] args) {
//Creating the object of Employee Class
Person person=new Person(\"Kane\",\"101 Church
Street\",\"kane@gamil.com\",991234568);
//Displaying the Person Details
System.out.println(person.toString());
//Creating the object of Student Class
Student s=new Student(0) ;
//Displaying the Student Details
System.out.println(s.toString());
//Creating the date Class Object
Date d=new Date(2016, 06, 31);
//Creating the object of Employee Class
Employee emp=new Employee(\"WIPRO\", 50000, d);
//Displaying the Employee Details
System.out.println(emp.toString());
//Creating the object of Faculty Class
Faculty faculty=new Faculty(8, \"Professor\");
//Displaying the Faculty Details
System.out.println(faculty.toString());
Staff staff=new Staff(\"Engineer\");
System.out.println(staff.toString());
}
}
______________________________________________________________
Person.java
public class Person {
//Declaring variables
private String name,address,email_address;
private long phone_number;
//Zero Argument Constructor
public Person() {
super();
}
//Parameterized constructor.
public Person(String name, String address, String email_address,
long phone_number) {
super();
this.name = name;
this.address = address;
this.email_address = email_address;
this.phone_number = phone_number;
}
//Setters and getters
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getEmail_address() {
return email_address;
}
public void setEmail_address(String email_address) {
this.email_address = email_address;
}
public long getPhone_number() {
return phone_number;
}
public void setPhone_number(long phone_number) {
this.phone_number = phone_number;
}
//toString() method displays the contents of the object.
@Override
public String toString() {
return \"Person [name=\" + name + \", address=\" + address + \", email_address=\"
+ email_address + \", phone_number=\" + phone_number + \"]\";
}
}
__________________________________________________
Student.java
public class Student extends Person {
//Declaring variables
private String status;
//Zero Argument Constructor
public Student() {
sup.
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
First compile all the classes.But to run the program we have to run .pdf
1. First compile all the classes.But to run the program we have to run the class which is having the
main method.
here TestEveryOne.java class is having the main() method.If we run the program we may get the
output.
Before Posting the code I checked for Errors twice,Only After ensuring that this programs are
having no errors and working fine am posting.If Any Problem Happened just do comment.I will
be available until you satisfied with my answer. _Thank you
To Compile .java file we have to use javac command like to compile javac TestEveryOne.java
To run the program we have to use java TestEveryOne.
_____________________________________________________________________
TestEveryOne.java
public class TestEveryOne {
public static void main(String[] args) {
//Creating the object of Employee Class
Person person=new Person("Kane","101 Church
Street","kane@gamil.com",991234568);
//Displaying the Person Details
System.out.println(person.toString());
//Creating the object of Student Class
Student s=new Student(0) ;
//Displaying the Student Details
System.out.println(s.toString());
//Creating the date Class Object
Date d=new Date(2016, 06, 31);
//Creating the object of Employee Class
Employee emp=new Employee("WIPRO", 50000, d);
//Displaying the Employee Details
System.out.println(emp.toString());
2. //Creating the object of Faculty Class
Faculty faculty=new Faculty(8, "Professor");
//Displaying the Faculty Details
System.out.println(faculty.toString());
Staff staff=new Staff("Engineer");
System.out.println(staff.toString());
}
}
______________________________________________________________
Person.java
public class Person {
//Declaring variables
private String name,address,email_address;
private long phone_number;
//Zero Argument Constructor
public Person() {
super();
}
//Parameterized constructor.
public Person(String name, String address, String email_address,
long phone_number) {
super();
this.name = name;
this.address = address;
this.email_address = email_address;
this.phone_number = phone_number;
}
//Setters and getters
public String getName() {
return name;
}
public void setName(String name) {
3. this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getEmail_address() {
return email_address;
}
public void setEmail_address(String email_address) {
this.email_address = email_address;
}
public long getPhone_number() {
return phone_number;
}
public void setPhone_number(long phone_number) {
this.phone_number = phone_number;
}
//toString() method displays the contents of the object.
@Override
public String toString() {
return "Person [name=" + name + ", address=" + address + ", email_address="
+ email_address + ", phone_number=" + phone_number + "]";
}
}
__________________________________________________
Student.java
public class Student extends Person {
//Declaring variables
private String status;
//Zero Argument Constructor
public Student() {
super();
4. }
//Parameterized constructor.
public Student(int status) {
super();
if(status==0)
this.status="Freshman";
else if(status==1)
this.status="Sophomore";
else if(status==2)
this.status="Junior";
else if(status==3)
this.status="Senior";
}
//Setters and getters
public String getStatus() {
return status;
}
public void setStatus(int status) {
if(status==0)
this.status="Freshman";
else if(status==1)
this.status="Sophomore";
else if(status==2)
this.status="Junior";
else if(status==3)
this.status="Senior";
}
//toString() method displays the contents of the object.
@Override
public String toString() {
return "Student [status=" + status + "]";
}
}
_________________________________________________
5. Employee.java
public class Employee extends Person {
//Declaring variables
private String office;
private double salary;
private Date date_hired;
//Zero Argument Constructor
public Employee() {
super();
}
//Parameterized constructor.
public Employee(String office, double salary, Date date_hired) {
super();
this.office = office;
this.salary = salary;
this.date_hired = date_hired;
}
//Setters and getters
public String getOffice() {
return office;
}
public void setOffice(String office) {
this.office = office;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
public Date getDate_hired() {
return date_hired;
}
public void setDate_hired(Date date_hired) {
this.date_hired = date_hired;
}
6. //toString() method displays the contents of the object.
@Override
public String toString() {
return "Employee [office=" + office + ", salary=" + salary
+ ", date_hired=" + date_hired + "]";
}
}
____________________________________________________________
Date.java
import java.util.Calendar;
public class Date {
//Declaring variables
private int year,month,day;
//Zero Argument Constructor
public Date() {
super();
Calendar now = Calendar.getInstance(); // Gets the current date and time
this.year=now.get(Calendar.YEAR);
this.month=now.get(Calendar.MONTH);
this.day=now.get(Calendar.DAY_OF_MONTH);
}
//Parameterized constructor.
public Date(int year, int month, int day) {
super();
this.year = year;
this.month = month;
this.day = day;
}
//Setters and getters
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
7. public int getMonth() {
return month;
}
public void setMonth(int month) {
this.month = month;
}
public int getDay() {
return day;
}
public void setDay(int day) {
this.day = day;
}
//toString() method displays the contents of the object.
@Override
public String toString() {
return +day +"-"+month+"-"+year;
}
}
_________________________________________________________
Faculty.java
public class Faculty extends Employee {
//Declaring variables
private int office_hours;
private String rank;
//Zero Argument Constructor
public Faculty() {
super();
}
//Parameterized constructor.
public Faculty(int office_hours, String rank) {
super();
this.office_hours = office_hours;
this.rank = rank;
}
//Setters and getters
public int getOffice_hours() {
8. return office_hours;
}
public void setOffice_hours(int office_hours) {
this.office_hours = office_hours;
}
public String getRank() {
return rank;
}
public void setRank(String rank) {
this.rank = rank;
}
//toString() method displays the contents of the object.
@Override
public String toString() {
return "Faculty [office_hours=" + office_hours + ", rank=" + rank + "]";
}
}
___________________________________________________________
Staff.java
public class Staff extends Person {
//Declaring variables
private String title;
//Zero Argument Constructor
public Staff() {
super();
}
//Parameterized constructor.
public Staff(String title) {
super();
this.title = title;
}
//Setters and getters
9. public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
//toString() method displays the contents of the object.
@Override
public String toString() {
return "Staff [title=" + title + "]";
}
}
_____________________________________________________________
Output:
Person [name=Kane, address=101 Church Street, email_address=kane@gamil.com,
phone_number=991234568]
Student [status=Freshman]
Employee [office=WIPRO, salary=50000.0, date_hired=31-6-2016]
Faculty [office_hours=8, rank=Professor]
Staff [title=Engineer]
______________________________________________________________________
Solution
First compile all the classes.But to run the program we have to run the class which is having the
main method.
here TestEveryOne.java class is having the main() method.If we run the program we may get the
output.
Before Posting the code I checked for Errors twice,Only After ensuring that this programs are
having no errors and working fine am posting.If Any Problem Happened just do comment.I will
be available until you satisfied with my answer. _Thank you
To Compile .java file we have to use javac command like to compile javac TestEveryOne.java
To run the program we have to use java TestEveryOne.
_____________________________________________________________________
TestEveryOne.java
public class TestEveryOne {
10. public static void main(String[] args) {
//Creating the object of Employee Class
Person person=new Person("Kane","101 Church
Street","kane@gamil.com",991234568);
//Displaying the Person Details
System.out.println(person.toString());
//Creating the object of Student Class
Student s=new Student(0) ;
//Displaying the Student Details
System.out.println(s.toString());
//Creating the date Class Object
Date d=new Date(2016, 06, 31);
//Creating the object of Employee Class
Employee emp=new Employee("WIPRO", 50000, d);
//Displaying the Employee Details
System.out.println(emp.toString());
//Creating the object of Faculty Class
Faculty faculty=new Faculty(8, "Professor");
//Displaying the Faculty Details
System.out.println(faculty.toString());
Staff staff=new Staff("Engineer");
System.out.println(staff.toString());
}
}
______________________________________________________________
11. Person.java
public class Person {
//Declaring variables
private String name,address,email_address;
private long phone_number;
//Zero Argument Constructor
public Person() {
super();
}
//Parameterized constructor.
public Person(String name, String address, String email_address,
long phone_number) {
super();
this.name = name;
this.address = address;
this.email_address = email_address;
this.phone_number = phone_number;
}
//Setters and getters
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getEmail_address() {
return email_address;
}
public void setEmail_address(String email_address) {
this.email_address = email_address;
12. }
public long getPhone_number() {
return phone_number;
}
public void setPhone_number(long phone_number) {
this.phone_number = phone_number;
}
//toString() method displays the contents of the object.
@Override
public String toString() {
return "Person [name=" + name + ", address=" + address + ", email_address="
+ email_address + ", phone_number=" + phone_number + "]";
}
}
__________________________________________________
Student.java
public class Student extends Person {
//Declaring variables
private String status;
//Zero Argument Constructor
public Student() {
super();
}
//Parameterized constructor.
public Student(int status) {
super();
if(status==0)
this.status="Freshman";
else if(status==1)
this.status="Sophomore";
else if(status==2)
this.status="Junior";
else if(status==3)
this.status="Senior";
13. }
//Setters and getters
public String getStatus() {
return status;
}
public void setStatus(int status) {
if(status==0)
this.status="Freshman";
else if(status==1)
this.status="Sophomore";
else if(status==2)
this.status="Junior";
else if(status==3)
this.status="Senior";
}
//toString() method displays the contents of the object.
@Override
public String toString() {
return "Student [status=" + status + "]";
}
}
_________________________________________________
Employee.java
public class Employee extends Person {
//Declaring variables
private String office;
private double salary;
private Date date_hired;
//Zero Argument Constructor
public Employee() {
super();
}
//Parameterized constructor.
public Employee(String office, double salary, Date date_hired) {
super();
14. this.office = office;
this.salary = salary;
this.date_hired = date_hired;
}
//Setters and getters
public String getOffice() {
return office;
}
public void setOffice(String office) {
this.office = office;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
public Date getDate_hired() {
return date_hired;
}
public void setDate_hired(Date date_hired) {
this.date_hired = date_hired;
}
//toString() method displays the contents of the object.
@Override
public String toString() {
return "Employee [office=" + office + ", salary=" + salary
+ ", date_hired=" + date_hired + "]";
}
}
____________________________________________________________
Date.java
import java.util.Calendar;
public class Date {
//Declaring variables
15. private int year,month,day;
//Zero Argument Constructor
public Date() {
super();
Calendar now = Calendar.getInstance(); // Gets the current date and time
this.year=now.get(Calendar.YEAR);
this.month=now.get(Calendar.MONTH);
this.day=now.get(Calendar.DAY_OF_MONTH);
}
//Parameterized constructor.
public Date(int year, int month, int day) {
super();
this.year = year;
this.month = month;
this.day = day;
}
//Setters and getters
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public int getMonth() {
return month;
}
public void setMonth(int month) {
this.month = month;
}
public int getDay() {
return day;
}
public void setDay(int day) {
this.day = day;
}
//toString() method displays the contents of the object.
16. @Override
public String toString() {
return +day +"-"+month+"-"+year;
}
}
_________________________________________________________
Faculty.java
public class Faculty extends Employee {
//Declaring variables
private int office_hours;
private String rank;
//Zero Argument Constructor
public Faculty() {
super();
}
//Parameterized constructor.
public Faculty(int office_hours, String rank) {
super();
this.office_hours = office_hours;
this.rank = rank;
}
//Setters and getters
public int getOffice_hours() {
return office_hours;
}
public void setOffice_hours(int office_hours) {
this.office_hours = office_hours;
}
public String getRank() {
return rank;
}
public void setRank(String rank) {
this.rank = rank;
17. }
//toString() method displays the contents of the object.
@Override
public String toString() {
return "Faculty [office_hours=" + office_hours + ", rank=" + rank + "]";
}
}
___________________________________________________________
Staff.java
public class Staff extends Person {
//Declaring variables
private String title;
//Zero Argument Constructor
public Staff() {
super();
}
//Parameterized constructor.
public Staff(String title) {
super();
this.title = title;
}
//Setters and getters
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
//toString() method displays the contents of the object.
@Override
public String toString() {
return "Staff [title=" + title + "]";
}
}
_____________________________________________________________