is it possible to inherit a class but methods declared in
the class should not be inheritable i possible how?
Answer Posted / ashish modi
class X
{
protected virtual void F() { Console.WriteLine("X.F"); }
protected virtual void F2() { Console.WriteLine
("X.F2"); }
}
class Y : X
{
sealed protected override void F() { Console.WriteLine
("Y.F"); }
protected override void F2() { Console.WriteLine
("X.F3"); }
}
class Z : Y
{
// Attempting to override F causes compiler error
CS0239.
// protected override void F() { Console.WriteLine
("C.F"); }
// Overriding F2 is allowed.
protected override void F2() { Console.WriteLine
("Z.F2"); }
}
Is This Answer Correct ? | 12 Yes | 2 No |
Post New Answer View All Answers
What is Private Constructor? and it’s use? Can you create instance of a class which has Private Constructor?
What is the difference between Java and .NET garbage collectors?
What is a console in c#?
What is a float?
Is a c# interface the same as a c++ abstract class?
Asha buys 16 Chocolates for rs 12 and 24 chocolates for rs 20, if she sold them 30 chocolates for rs 30 then what is the Gain/Loss percentage? Gain(700/19 %) Loss(700/19 %) Gain(500/19 %) Loss(500/19 %) If one person ate 100 grapes in 5 days and 6 more each day from starting, what was the no of grapes he ate on first day? 6 8 10 7 If seven men P, Q, R, S, T, U, V parked his car, P and Q something like that. 6 student J, K, L, M, N, O went for picnic in 2 batches, K and L have to go together, M and O do't go together, if O and L go in one batch then which of these combination will be wrong. Jmnp Jklo klop JKLO a boat can go upstream and down stream, if it goes 5/2 times of downstream at the speed of 6 kmph then what will be the speed of upstream? 15 KMPH 12 KMPH 10 KMPH 11 KMPH A, B, C, D, E sitting on a table, A sits 2 seat left from B and C sits 2 seat right from B then what will not be the combination ACDE
Explain how can you clean up objects holding resources from within the code?
What is decimal in c#?
What is the difference between CONST and READONLY?
Why are dynamic link library used over static one?
How to parse a date time string?
What is a shared assembly?
What is a protected class in c#?
What is a scope in c#?
What is an interface class in c#?