Net Question and Answersocx
Net Question and Answersocx
Sealed class is used to prevent the class from being inherited from other classes. So
“sealed” modifier also can be used with methods to avoid the methods to override in the
child classes.
class X {}
sealed class Y : X {}
Sealed methods –
class A
class B : A
Array stores the values or elements of same data type but arraylist stores values of
different datatypes.
Arrays will use the fixed length but arraylist does not uses fixed length like array.
“Static” keyword can be used for declaring a static member. If the class is made static then
all the members of the class are also made static. If the variable is made static then it will
have a single instance and the value change is updated in this instance.
No. We can’t override private virtual methods as it is not accessible outside the class.
Lock will make sure one thread will not intercept the other thread which is running the part
of code. So lock statement will make the thread wait, block till the object is being released.
When methods are created with the same name, but with different signature its called
overloading. For example, WriteLine method in console class is an example of overloading.
In the first instance, it takes one variable. In the second instance, “WriteLine” method takes
two variable.
Console.WriteLine(x);
In C#, derived classes can inherit from one base class only. If you want to inherit from
multiple base classes, use interface.
class Car
public Car()
public Ford()
To override a base class method which is defined as virtual, Override keyword is used. In
the above example, method DriveType is overridden in the derived class.
MVC is a framework used to create web applications. The web application base builds
on Model-View-Controller pattern which separates the application logic from UI, and the input
and events from the user will be controlled by the Controller.
The short answer would be: in the Stack are stored value types (types
inherited from System.ValueType ), and in the Heap are stored reference
types (types inherited from System.Object ).
We can say the Stack is responsible for keeping track of what is actually
executing and where each executing thread is (each thread has its own
Stack). The Heap, on the other hand, is responsible for keeping track of
the data, or more precise objects.
An interface, on the other hand, can declare properties, methods and events only (no
access modifiers). The developer must implement all declared members. In short, an
interface designates a contract/behavior that implementing classes should have.
When should you use .NET Web Forms over ASP.NET MVC?
Traditionally, the .NET framework has been based on web forms. This was essentially an
effort to create web services using Microsoft’s existing Visual tools without forcing
developers to learn new scripting languages. Web Forms still allows developers to create
quick and simple applications, and some legacy systems may still run as Web Forms.