Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7734319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:13:14+00:00 2026-06-01T07:13:14+00:00

For my homework, we’ve been tasked with declare an array of four regular College

  • 0

For my homework, we’ve been tasked with “declare an array of four “regular” College Employees, three Faculty and seven Students. Prompt the user to specify which type of data will be entered (C,F,S) or the option to Quit (Q). While the user continues, accept data entry for the appropriate person. Display an error message if the user enters more than the specified number for each person type. When the user quits, display a report on the screen listing each group of persons under the appropriate heading. If the user has not entered data for one or more types of Person during a session display an appropriate message under the appropriate heading.”

    Class           | Extends         | Variables
--------------------------------------------------------
    Person          | None            | firstName, lastName, streetAddress, zipCode, phone
    CollegeEmployee | Person          | ssn, salary,deptName
    Faculty         | CollegeEmployee | tenure(boolean)
    Student         | person          | GPA,major

After reading the Tutorials on inheritance and trolling a bunch of inheritance discussions, I think I’ve got it right on paper, but would prefer some input before I get elbows deep in code that doesn’t work. 🙂

I’m defining

Person[x] = new Student();

(or Faculty or CollegeEmployee).

The Person class has all the input fields for a Person, and the subclasses have ONLY the additional data (e.g., major in the case of Student).

When I create the new Student(); the input fields in BOTH the People and Student classes will be available to me because Student extends People and the additional variables defined in Student are appended to the definition of Person for that instance.

When it comes time to pull data from the array, Java sees it as an array of Person, so I need to add logic

if Person[x] instanceof Student (or `Faculty` or `CollegeEmployee`)

to execute the appropriate actions for the type of Person. My sense is that the instanceof is acting to override (in this case to append to) what Java knows about the Person class on the output side.

Am I missing any critical understandings of this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T07:13:16+00:00Added an answer on June 1, 2026 at 7:13 am

    There is not only inheritance, but polymorphism – just put code necessary to enter and validate object data in method of object (say: inputMyData() overriding base method in person, possibly calling method of superclass) – this way you can avoid instanceof and casting.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Homework. Dice Game. I've got an array that represents five rolls of a die.
For homework, I'm working with the following three classes. Class | Extends | Variables
My homework assignment is telling me to declare a class inline, but I've only
This is a homework problem that I have. I have been doing some research
My homework has a problem for example there is a category array $cat=array('1','4','5','7'); now
For a homework assignment, I was tasked with creating a Ping Pong layer that
For my current homework, I'm trying to sort my array through a generic class
Doing homework and I'm stuck. Let's say I have an array colors: [blue, orange,
Homework: Consider the two-dimensional array A: int A[][] = new int[200][200]; where A[0][0] is
Homework: Rock Paper Scissors game. I've created an enumeration: enum Gesture{ROCK,PAPER,SCISSORS}; from which I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.