OOPs
Reasoning FAQs-1
S.No |
Questions |
Answers |
1 |
Does c# support
multiple-inheritance ? |
No. Multiple
inheritance is not possible in .NET. This means it is not possible
for one class to inherit from multiple classes. However, a class
may implement multiple interfaces. We may also declare objects of
different classes in a class. This way, the encapsulated class may
be instantiated in other classes. |
2 |
Do events have
return type ? |
Events do not have
return type. |
3 |
Can you override
private virtual methods ? |
No, we cannot
access private methods in inherited classes. |
4 |
Can you allow
class to be inherited, but prevent the method from being
over-ridden ? |
Yes,
just leave the class public and make the method sealed.
|
5 |
Can
we have shared events ?
|
Yes, we can have
shared event’s note only shared methods can raise shared events. |
6 |
Can
you write a class without specifying namespace ? which namespace
does it belong to by default ?
|
Yes, we can, then
the class belongs to global namespace which has no name. For
commercial products, naturally, we would not want global
namespace. |
7 |
Can you prevent
a class from overriding ? |
Yes.If
we define a class as “Sealed” in C# and “NotInheritable”
in VB.NET we can not
inherit the class
any further. |
8 |
Are
private class-level variables inherited ?
|
Yes, but they are
not accessible. Although they are not visible or accessible via
the class interface, they are inherited. |
9 |
Can
you declare the override method static while the original method
is non-static?
|
No,
we can't, the signature of the virtual method must remain the
same, only the keyword virtual is changed to keyword override.
|
10 |
Can
a constructors that is declared within a base class, inherited by
subclasses ?
|
No, constructors
that are declared within a base class cannot be inherited by
sub-classes. If we have not declared any constructor in our class
then a default constructor is provided. |
No comments:
Post a Comment