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 6777649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:10:23+00:00 2026-05-26T16:10:23+00:00

I have question regarding polymorphism about its assignment statement, for Example this is The

  • 0

I have question regarding polymorphism about its assignment statement, for Example this is The Super class

   public class Person {

            private String firstName;
            private String middleInitial;
            private String lastName;
            private int age;

            public Person(String firstName,String middleInitial , String lastName , int age){
                setFirstName(firstName);
                setMiddleInitial(middleInitial);
                setLastName(lastName);
                setAge(age);
            }

            public void setFirstName(String firstName){
                this.firstName = firstName;
            }

            public String getFirstName(){
                return firstName;
            }

            public void setMiddleInitial(String middleInitial){
                this.middleInitial = middleInitial;
            }

            public String getMiddleInitial(){
                return middleInitial;
            }

            public void setLastName(String lastName){
                this.lastName = lastName;
            }

            public String getLastName(){
                return lastName;
            }

            public void setAge(int age){
                this.age = age;
            }

            public int getAge(){
                return age;
            }

            public String toString(){
                return String.format("First Name: "+getFirstName()+"\nMiddle Initial: "+getMiddleInitial()+
                                        "\nLast Name: "+getLastName()+"\nAge: "+getAge());
            }
    }

And this is The Derived Class

 public class Employee extends Person{

        private Contact contact;

        public Employee(String firstName,String middleInitial , String lastName , int age, Contact contact){
            super(firstName,middleInitial,lastName,age);
            this.contact = contact;
        }
public String toString(){
        return String.format(super.toString()+contact.toString());
    }
}

Now my question is what’s the Difference Between these assignment statements ?? and what are the difference ? I know Employee is a Person but I want to know what’s the difference between these two:

 Person employee1 = new Employee();
    Employee employee2 = new Employee();

and This

 Employee employeeKyle = new Employee();
    Person employeeKyel2 = employeeKyle;

I am kinda having a hard time about these .

  • 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-05-26T16:10:24+00:00Added an answer on May 26, 2026 at 4:10 pm

    In the first one you have 2 OBJECTS, both are of the type Employee, and you have 2 different references to them, one being a Person reference and the other being an Employee reference.

    In the second case, you have 1 OBJECT with 2 REFERENCES pointing to it, being one a Person and another an Employee.

    The object is always of the type you’ve instantiated it with the new keyword (in this case, the object is always an employee). You can, however, have different types of references pointing to the actual object (the references can be either of the type of the object or of one of its superclasses).

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

Sidebar

Related Questions

I have a question regarding the following code: abstract class a { public static
I have a question regarding inheritance in Java. If I have this base class
I have question regarding the SQLAlchemy. How can I add into my mapped class
I have a question regarding dependency injection. say i want to create a class
I have question regarding RESTful resources similar to this other question . We're also
I have a question regarding GetTickCount function, I have two calls to this function
I have general question regarding the use of pointers vs. references in this particular
I have a question regarding this code. I'm a beginner and enjoy learning C#.
I have question regarding about finding subview using '.tags' in one UIView. for (UIView
I have a question regarding how to use JSON integration in Android. For example

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.