Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Can we have the method in drived class with the same name
which is there in base class?

Answer Posted / brijender p rana

It is possible to hide the base class method with the
derived class without using Virtual in base class and
Override keyword in subclass.there are some condition where
we have to redefine any method in derived class same name
in base class now question arise how can we hide the method
anwer is simple and logical we use the modifier NEW which
tell the compiler that derived class method "hides the base
class method. There are some example:
Class baseclass
{
Public void display()
{
console.writeline("base method");
}
}
class derived : baseclass
{
public new void display()
{
console.writeline("dervied mthod");
}
}
class test
{
public static void main()
{
derived d=new derivedclass();
d.display();
}
}

Is This Answer Correct ?    5 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between CreateObject() and GetObject()?

1039


What is public void in c#?

950


How is the syntax written to inherit from a class in C#?Give an example ?

1023


What is static noise?

868


What do you mean by object pooling?

950


What is use of a HashTable in .NET?

1105


Write a program to find the angle between the hours and minutes in a clock

880


what is c# command?

939


How do you pass reference parameters in c#?

870


Explain the process of abstraction with an example?

894


What is static variable in c#?

911


What is the use of console readkey ()?

948


While debugging a C# application can you change the value of a variable?

990


What is strong name assembly?

829


What is a verbatim string literal and why do we use it?

906