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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:50:41+00:00 2026-05-18T20:50:41+00:00

Person studentA = new Student(); Person is a base class Student is a sub

  • 0
Person studentA = new Student();

Person is a base class
Student is a sub class of Person.

Why would anyone use the line of code above for? Why don’t you just do

Student studentA = new Student();
  • 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-18T20:50:41+00:00Added an answer on May 18, 2026 at 8:50 pm

    Sometimes you want to refer to an object in a more general sense. Most people understand user interfaces so here is a basic example:

    Suppose you have a screen where you want every control to be disabled until some sort of cue, ie. a user fills in some initial input. Your controls may be things like Textboxes, Comboboxes (dropdowns), or Buttons. A way you can refer to all of the above in one fell swoop is to treat them as Controls.

    You might write code like:

    foreach(Control c in MyForm.Controls)c.Enabled = false;
    

    This is one example but as you start programming more you’ll see this is a pretty basic part of your object oriented existence.

    One place where you can see most object oriented base class libraries employ this technique is with I/O – all input and output libraries available. In the most abstract sense you’ll have a Stream but when you look at the class hierarchy you’ll see polymorphic variations of the Stream concept: a file stream, a network stream, and so on. Reading and writing stream implementations will be done with “Readers” and “Writers” respectively. Doing some basic programming tasks will get you a really nice feel for how useful this polymorphism is. For example, writing code that reads from a stream and then abstracting it so that it can apply to any implementation of Stream that it is handed.

    One thing I always try to suggest to people is to study the built in libraries to see how framework designers and programmers employ techniques like this effectively for very practical day to day usage.

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

Sidebar

Related Questions

The following code breaks the Law of Demeter : public class Student extends Person
I have four classes. Class Person , and three more, Student , Professor ,
I have implemented single table inheritance for a person class class Person < ActiveRecord::Base
I need to represent inheritance like Person/Student. How do you do that in LInqToSql?
I have two entities person and Student , the student entity extends person and
Given the classes: public class Person { public string Name { get; set; }
I am experimenting with Hibernate to gain experience. I created a class Person with
I don't know if anyone has watched the Visual Studio 2008, Linq to SQL,
Consider the following example where Student inherits from Person : function Person(name) { this.name
I have a Personnel class, where I store all of Objects of type student,

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.