According to the comment:
This is an interview question, I think you can make any guess here
If so, the only correct answer is to describe your assumptions and how to solve them.
If you strictly adhere to the requirements, you can make the Student and Employee interfaces and implement different classes:
public interface Student { void learn(); } public interface Employee { void work(); } public class Person {
Taking the extra mile, you need to extract the logic work() and learn() in the helper classes and call StudentPerson , EmployeePerson and StudentEmployeePerson respectively.
But this, IMHO, missed the point of the exercise.
A student who also has a job is still a student. It cannot be a separate class for a student who does not.
I would create a Role interface, have Student and Employee implement it, and allow Person have multiple Role s, so it can be both a student and an employee:
public interface Role { void perform(); } public class Student implements Role { @Override void perform() { } } public class Employee implements Role { @Override void perform() { } } public class Person {
EDIT:
To answer the question in the commentary, a person who is both a student and an employee will be built by adding Role s. For simplicity, the following snippet assumes that these classes have constructors from the corresponding properties and that Person has methods for adding and removing Role to the internal set:
Person person = new Person ("John Doe", 21, Sex.Male); person.addRole (new Student ("StackOverflow University")); person.addRole (new Employee ("Secret Government Spy"));