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
Can you inherit from multiple classes in c#?
What is use of abstract class in c#?
Why do we use yield in c#?
How do you achieve polymorphism in c#?
What is difference between private and protected in c#?
What is get set in c#?
How many types of constructors are there in c#?
What is an enumerator in c#?
What is a partial class. Give an example?
What is state c#?
What is sorted list in c#?
If you want to convert a base type to a derived type, what type of conversion do you use?
Explain About CLS?
Explain how do I convert a string to an int in c#?
The int maps to which C# keyword in .NET type?