Inheritance in Java OOP – Code Example 2

In previous post we learned about inheritance in Java programming by using simple code example. In this post we will consider another code example of inheritance in Java. In previous post we created a Car class (child class) which inherited some attributes and methods from Vehicle class (parent class). In this post we will create a Student class (child class) which will inherit attributes and methods from Human class (parent class). [js] //Student class code: package learningclassesaobjects; public class Student extends Human { int rollNo; public void setRollNo(int x){ rollNo = x; } public void getRollNo(){ System.out.printf("Your Roll No is:...
forward