oops concept query

0 votes

This is my oops question.

This is my base class

public class BaseClass
{
   public int i = 10;
   public int x = 30;
   public string str = "Hello";
   public virtual string Hello()
   {
     return "Hello of base class called";
   }
}

This is my child class

public class ChildClass : BaseClass
{
    public int i = 20;
    public int z = 90;
    public override string Hello()
    {
       return "Hello of child class called";
     }
}

I have noticed that following works fine

BaseClass baseObject = new ChildClass();

and if I enter baseObject, then only members of BaseClass are shown

  1. Can someone provide me some advice on a circumstance in which a developer needs to do something like BaseClass baseObject = new ChildClass();?
  2. Why are my child member variables not accessible through this baseObject if my BaseClass object has a reference to my child class object?
Jun 11 in C# by jyoti
• 1,140 points
5 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In C#

0 votes
1 answer

Examples of dynamic polymorphism in c#

Check the example of polymorphism below. We ...READ MORE

answered Jun 7 in C# by pranav
• 2,320 points
12 views
0 votes
1 answer

Object Oriented Programming Basic Concept(C#)

Use this link https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/access-modifiers protected internal: The type or ...READ MORE

answered Jun 17 in C# by jyoti
• 1,140 points
9 views
0 votes
1 answer
0 votes
2 answers

Is there a .NET equivalent to Apache Hadoop?

Hadoop is a Java-based platform. So, to ...READ MORE

answered Jul 16, 2020 in Big Data Hadoop by Suhana
• 340 points
632 views
0 votes
3 answers

Explain OOPs concept in python with programatic examples

Understanding OOPs is a gradual process and ...READ MORE

answered Nov 24, 2020 in Python by William
• 140 points
804 views
+1 vote
1 answer

R query and Data Science

Dear Deepika, Hope you are doing great. You can ...READ MORE

answered Dec 18, 2017 in Data Analytics by Sudhir
• 1,610 points
224 views
0 votes
1 answer

How Impala is fast compared to Hive in terms of query response?

Impala provides faster response as it uses MPP(massively ...READ MORE

answered Mar 21, 2018 in Big Data Hadoop by nitinrawat895
• 11,380 points
1,131 views
+16 votes
4 answers
0 votes
1 answer

MDX query in Tableau pivot table

You can view them here - \My Documents\My ...READ MORE

answered Apr 6, 2018 in Tableau by QueenBee
• 1,820 points
389 views
0 votes
2 answers

Hadoop query regarding setJarByClass method of Job class

http://www.bigdataspeak.com/2014/06/what-is-need-to-use-jobsetjarbycla ...READ MORE

answered Feb 7, 2019 in Big Data Hadoop by siri
1,397 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP