Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question Goal: Apply ideas about availability and overriding methods Assignment: Imagine that you are a paleontologist that is working on classifying different species of early

Question
Goal: Apply ideas about availability and overriding methods
Assignment: Imagine that you are a paleontologist that is working on classifying different species of early hominids. While still relatively diverse in their characteristics and abilities, many early hominids already shared some key features, notably, bipedalism.
The class Hominid has already been created for you. This class defines the variables locomotion which has the final modifier, and speciesName which is protected. The class also defines the method describe which prints the species name and locomotion. The class constructor assigns the value of speciesName upon instantiation.
Create two classes, Australopithicus and Homo Habilis that meet the following requirements:
They cannot be inherited.
They Define a String variable era.
They have a constructor method that:
Invokes the contructor method of the Hominid class
Initializes the species name to "Australopithecus afarensis" or "Homo habilis".
Takes era as an argument and declares it as a class property to be defined by the user.
They override the description method by invoking the description method of the Hominid class and then print "This species lived in the era."
// Base class Hominid
class Hominid {
// Final variable, consistent among all hominids
public final String locomotion = "bipedal";
// Protected variable, which might differ between different hominid species
protected String speciesName;
// Constructor for Hominid class
public Hominid(String speciesName){
this.speciesName = speciesName;
}
// Protected method to describe the species, can be overridden
protected void describe(){
System.out.println("Species: "+ speciesName);
System.out.println("Locomotion "+ locomotion);
}
}
(THE CODE ABOVE IS WHAT I HAVE SO FAR)

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

Accounting And Auditing Research And Databases Practitioner's Desk Reference

Authors: Thomas R. Weirich, Natalie Tatiana Churyk, Thomas C. Pearson

1st Edition

1118334426, 978-1118334423

More Books

Students also viewed these Databases questions

Question

Understand the role of employer branding in talent management.

Answered: 1 week ago