-
Can you declare the override method static while the original method is non-static?
No, you cannot, the signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override.
-
Can you override private virtual methods?
No, moreover, you cannot access private methods in inherited classes, have to be protected in the base class to allow any sort of access.
-
Can you prevent your class from being inherited and becoming a base class for some other classes?
Yes, that is what keyword sealed in the class definition is for. The developer trying to derive from your class will get a message: cannot inherit from Sealed class WhateverBaseClassName. It is the same concept as final class in Java.
-
-
C# provides a default constructor for me. I write a constructor that takes a string as a parameter, but want to keep the no parameter one. How many constructors should I write?
Two. Once you write at least one constructor, C# cancels the freebie constructor, and now you have to write one yourself, even if there's no implementation in it.
-
-
Which of these .NET languages has been specefically designed to be used with .NET?
Skill/Topic: IntermediateA) Visual C++ .NETB) C#C) VB.NET
-
Namespaces are used to
Skill/Topic: IntermediateA) Separate assembliesB) Create a unique name for an assemblyC) Avoid name clashes between data types
-
Interfaces provide implementation of methods
Skill/Topic: IntermediateA) TrueB) FalseExplanation: They only provide declaration on methods, events and properties
-
Structs and classes support inheritance
Skill/Topic: IntermediateA) TrueB) FalseExplanation: Only classes can inherit. Structs can�t.
-
Method Overloading and Overriding are the same
Skill/Topic: IntermediateA) TrueB) FalseExplanation: Overloading is changing the behavior of a method in a derived class, whereas overriding is having multiple methods with the same name
-
Can we use pointers in C#?
Skill/Topic: AdvancedA) YesB) NoExplanation: Pointers can be used if required, but it will be unsafe code.
-
Applications running in different App Domains can't communicate with each other:
Skill/Topic: AdvancedA) TrueB) FalseExplanation: The can communicate
-
Platform specific code is obtained when
A) source code is compiled to get MSILB) when MSIL is compiled by CLRC) Both of the aboveExplanation: When CLR compiles the managed it generates the native code which is compatible to platform.
-
Which of the following is not a subclass of Value Type class
A) EnumerationsB) User defined value typesC) Boxed value typesExplanation: Boxed value types are of reference types
-
.NET run time relies on the object reference counts to manage memory
A) TrueB) FalseExplanation: .Net run time relies on Garbage Collection to manage memory
-
Which modifiers hides an inherited method with same signature
A) NewB) VirtualC) SealedExplanation: New hides the inherited method which was overridden by base class
-
How do you determine the size required by a Value type on the stack
A) Length operatorB) Sizeof operatorC) Mem operator
-
Which of the following can not be declared as virtual
A) Static functionsB) Member fieldsC) Instance functions
-
C# Interview Questions
Ans