Question
For ****JAVA**** In this assignment you will design a program that creates a class, then extends the class using Inheritance. You may pick any base
For ****JAVA****
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, or television. Then you must extend the class at least once.
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started