C Interview Questions Answers C For Freshers Experienced
C Interview Questions Answers C For Freshers Experienced
Sealed methods:
class A
{
protected virtual void First() { }
protected virtual void Second() { }
}
class B : A
{
sealed protected override void First() {}
protected override void Second() { }
}
If any class inherits from class “B” then method – “First” will not be overridable as
this method is sealed in class B.
Q: What is the difference between “throw ex” and “throw” methods in C#?
“throw ex” will replace the stack trace of the exception with stack trace info of re
throw point.
“throw” will preserve the original stack trace info.
Q: What are the differences between static, public and void in C#?
Static classes/methods/variables are accessible throughout the application without
creating instance. Compiler will store the method address as an entry point.
Public methods or variables are accessible throughout the application.
Void is used for the methods to indicate it will not return any value.
static MyClass()
{
Console.WriteLine(“Static Constr Test”);
}
public MyClass(MyClass myobj) // Copy Constructor
{
prop1 = myobj.prop1;
prop2 = myobj.prop2;
}
}
interface Wheels
{
void WheelType();
}