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 a non static member function in a base class to
be override in derived with static modifier?

Answers were Sorted based on User's Feedback



Can we have a non static member function in a base class to be override in derived with static mod..

Answer / guest

No.
A Static member can not be declared override, virtual,
abstract.

Is This Answer Correct ?    6 Yes 0 No

Can we have a non static member function in a base class to be override in derived with static mod..

Answer / parmjit

No, we cannot derive static class from a user defined
class. They can only be derived from object class.

Is This Answer Correct ?    2 Yes 0 No

Can we have a non static member function in a base class to be override in derived with static mod..

Answer / siva

No We cannot Create. It shows an error.

A static member 'Analysis.Class3.ss1()' cannot be marked as
override, virtual, or abstract

class Class2
{
public Class2()
{
}
public virtual void ss1()
{
System.Windows.Forms.MessageBox.Show("Base :
ss1");
}
}
class Class3:Class2
{
public Class3()
{
}
public static override void ss1()
{
System.Windows.Forms.MessageBox.Show
("Derived:s1");

}

}

Is This Answer Correct ?    2 Yes 0 No

Can we have a non static member function in a base class to be override in derived with static mod..

Answer / sanjay

No We cant ovver ride static member function in a base
class.

Is This Answer Correct ?    1 Yes 0 No

Can we have a non static member function in a base class to be override in derived with static mod..

Answer / srinivas

yes we can have a nonstatic membe function in the base ,
which can be override in derived class with static modiier.

for ex:
class sample
{
public:
static void get(){cout<<"this is base class
function:"<<endl;}
static void put(){cout<<"this is a put function of
base class :"<<endl;}
};
class sample1:public sample
{
public:
void put(){cout<<"this is a derived class
function:"<<endl;}
};
sample class is havinfg a non static member function put
which is overidden in dervied which static key word.

Which runs fine.

Is This Answer Correct ?    1 Yes 1 No

Can we have a non static member function in a base class to be override in derived with static mod..

Answer / srinivas

sorry i have given the reverse once . Even the reverse
works fine..

class sample
{
public:
static void get(){cout<<"this is base class
function:"<<endl;}
void put(){cout<<"this is a put function of base
class :"<<endl;}
};
class sample1:public sample
{
public:
static void put(){cout<<"this is a derived class
function:"<<endl;}
};

Is This Answer Correct ?    1 Yes 1 No

Can we have a non static member function in a base class to be override in derived with static mod..

Answer / kishore.a

We cannot override the non static method with a static
method in derived class.

Because all static members are handled directly by CLR.
Where as non static members are handled by CLR after object
instantiation.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Sharp Interview Questions

What is the difference between delegates and events in c#?

0 Answers  


How to parse a date time string?

0 Answers  


What does Dispose method do with the connection object?

2 Answers  


Can you prevent your class from being inherited and becoming a base class for some other classes?

3 Answers  


Valuetype/reference type?

6 Answers   Microsoft,


What is the difference between method and function in c#?

0 Answers  


In object oriented programming, how would you describe encapsulation in c#?

0 Answers  


What is the use of ienumerable?

0 Answers  


How many types of methods are there in c#?

0 Answers  


What is instantiating a class?

0 Answers  


Can we have only “try” block without “catch” block in c#?

0 Answers  


What is difference between virtual and override in c#?

0 Answers  


Categories