Question: In this assignment you will design a program that creates a class, then extends the class using Inheritance. You may pick any base class, such
In this assignment you will design a program that creates a class, then extends the class using Inheritance. You may pick any base class, such as car, television, etc. Then you must extend the class at least once.
****************In JAVA**************
import java.io.PrintStream;
public class Sub_class extends Super_class { int num = 10; public void display() { System.out.println("This is the display method of subclass"); } public void my_method() { Sub_class sub = new Sub_class(); sub.display(); super.display(); System.out.println("value of the variable named num in sub class:" + sub.num); System.out.println("value of the variable named num in super class:" + this.num); } public static void main(String[] args) { Sub_class obj = new Sub_class(); obj.my_method(); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
