Question: Java programming language r:r mobily li.. Lab 07 Inheritance and Final Modifier COLiLeE of COMPUTER SCIENCESINFORMATION KING FAISAL UNIVERSITY, SAUDI ARABIA Experiment No. 1: Simple
r:r mobily li.. Lab 07 Inheritance and Final Modifier COLiLeE of COMPUTER SCIENCESINFORMATION KING FAISAL UNIVERSITY, SAUDI ARABIA Experiment No. 1: Simple Inheritance Example Inheritance is another one of the four fundamental OOP concepts. We just learned encapsulation in Lab 6 and we will learn polymorphism and abstraction in the next 2 Labs Inheritance is the concept that involves a subclass (child class) inheriting all public and protected components (attribute, method) of a superclass (parent class). Constructors are not inherited You will know there's inheritance when a class (subclass) extends another class (superclass). Let's create a KSAInfoSys project that contains the classes specified in the class diagranm below Person Student qamaNum: int studentID: int name: String +Person (int, String) + getlqamaNum(): int + setlqamaNum(int) + getName(): String + setName(String) + displayPerson() +Student (int, int, String) As shown in the class diagram above, the Student class has an arrow pointing to the Person class. This means that Student is a sub class and Person is its super class. In other words, Student class is a child of the Person class. Therefore, Student class will inherit the public and protected attributes (there is none) and methods (there are 5) of the Person class. You can do the Person class on your own but make the displayPerson0 method similar to the snippet below public void displayPerson) System.out.printIn "lqama No.:"+this.iqamaNum System.out.printin Name: +this.Name): OOP1 Lab 7 (2017 Revision) Page 5 of 8
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
