public class Person extends Employee{private String firstName;private String lastName;
public Person(String firstName,String lastName){this.firstName=firstName;this.lastName=lastName;}
}
Person is a class which inherits Employee and see the code below where Employee also inherit the Class Person.
In the above code we will see the error message "cyclic inheritance involving Person public class Person extends Employee" Actually Person should be the super class here and Employee is the subclass. But here the relationsship is such that Employee is the subclass of Person, again Person is the subclass of Employee. It's a cyclic inheritance which is not possible. The solution of this problem is identifying the proper relationship i.e, finding out the super class and the subclass. In our case Person is the super class, so it should not try to inherit Employee and Employee is the subclass which will inherit Person. Correction is ommiting "extends Employee" from the Person class signature as below:
Subscribe to:
Post Comments (Atom)
|
0 comments:
Post a Comment