Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro PowerShell For Database Developers

Authors: Bryan P Cafferky

1st Edition

1484205413, 9781484205419

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago