There are a class A. Another class B derived from it.
Now if I do A a = new B(); and B b = new B(); What will
happen in both the statements. And what is the difference
between these two statements.




Answer Posted / ashok kumar

A is a base class, B is a derived class.
Which means we cad access all the data of A class in B class.

Public A
{...}
Public B:A
{...}
Class VoidMain()
{
A a=new B();// Creating object for A class(can access the A
class data only).
B b=new B();// Creating object for B class(can access the
A,B class data).
}

Is This Answer Correct ?    12 Yes 3 No






Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can you instantiate a struct without using a new operator in c#?

11


How to assign Null value to Var?

19


How to sign an assembly with strong name?

17


I want to print "Hello" even before main() is executed. How will you achieve that?

21


What is the ouput of the following program?

4






From which base class do all Web Forms inherit from?

25


Compare and contrast between the System.Array.CopyTo() and Clone()?

23


Explain about CTS?

32


Is it possible to restrict the scope of a field/method of a class to the classes in the same namespace?

9


What are the 3 different types of arrays?

8


What is type cast in C#?

21


how background thread access to ui control?

20


What is difference between C# and VB.NET?

19


What are destructors in C#?

20


Which namespace is required to implement trace ?

23