The document discusses inheritance in Java through three tasks. It describes three class files - Person, Student, and Teacher, with Person as the parent class and the others as subclasses extending it. It notes the m2() and toString() methods are overridden in the subclasses using the @override keyword. The super keyword is used to invoke methods from the parent Person class. Files are provided to demonstrate inheritance and method overriding between the classes.
The document discusses inheritance in Java through three tasks. It describes three class files - Person, Student, and Teacher, with Person as the parent class and the others as subclasses extending it. It notes the m2() and toString() methods are overridden in the subclasses using the @override keyword. The super keyword is used to invoke methods from the parent Person class. Files are provided to demonstrate inheritance and method overriding between the classes.
The document discusses inheritance in Java through three tasks. It describes three class files - Person, Student, and Teacher, with Person as the parent class and the others as subclasses extending it. It notes the m2() and toString() methods are overridden in the subclasses using the @override keyword. The super keyword is used to invoke methods from the parent Person class. Files are provided to demonstrate inheritance and method overriding between the classes.
seen all the given codes for the file “IfElseForgrams”.
Inheritance
Task: 01
a.There are 3 class files.Person,Student,Teacher.
c.Person.java is the superclass means its the parent class. d.Teacher.java is the subclass or child class which extends person class e.Student.java is also a subclass or child class which extends person class. g. Changed the inputs for Person, Teacher and Student objects.
Task: 02
2.a.The name of the methods that are getting
ovrridden is, m2() and toString() methods. 2.b.@override keyword used for changing the methods of parent class. 3.c. The function of the super keywoed is to invoke the constructor or methods from super class.