Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

package com.mac 1 9 0 . inheritance; / * Inheritance is used whenever an object of a class can be considered as also an object

package com.mac190.inheritance;
/*
Inheritance is used whenever an object of a class can be considered as also an object
of another class. Example: I have a class Animal, you want to design a class Dog, A Dog IS
an animal, then the class Dog should be designed using inheritance from class Animal.
When inheritance is used a class inherits all member variables and methods of the inherited class.
Still private members of the parent class cannot be accessed directly by the inherited/child class.
If an inherited class needs to access member variables of a parent class, then you can use protected.
protected can be accessed by inherited class but not the public.
Let's have an example:
create a class animal that has the following:
color, age, species, diet
toString, equals
method speak() to display I don;t know how to speak yet!.
*/
public class Animal {
}

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_2

Step: 3

blur-text-image_3

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

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions

Question

17. Find the g-inverse of the matrix A where --- OCR End ---

Answered: 1 week ago

Question

What are the best practices for managing a large software project?

Answered: 1 week ago

Question

How does clustering in unsupervised learning help in data analysis?

Answered: 1 week ago