C#.Net Interview Question and Answers

116. What is the syntax to inherit from a class in C#?
 
  • When a class is derived from another class, then the members of the base class become the members of the derived class.
  • The access modifier used while accessing members of the base class specifies the access status of the base class members inside the derived class.
  • The syntax to inherit a class from another class In C# is as follows :
    class MyNewClass : MyBaseClass
 
Your Name Your Email-ID
Your Answer
117. What is a basic difference between the while loop and do while loop in C#?
  The while loop tests its condition at the beginning, which means that the enclosed set of statements run for zero or more number of times if the condition evaluates to true. The do while loop iterates a set of statements at least once and then checks the condition at the end.
 
Your Name Your Email-ID
Your Answer
118. What is the main difference between a subprocedure and a function?
  Subprocedures do not return a value, while functions do.
 
Your Name Your Email-ID
Your Answer
119. What are sealed classes in c#?
 
  • The sealed modifier is used to prevent derivation from a class.
  • A compile time error occurs if a sealed class is specified as the base class of another class.
 
Your Name Your Email-ID
Your Answer
120. What is the difference between class and an Interface?
 
  • Abstract classes can have implementations for some of its members, but the interface can't have implementation for any of its members.
  • Interfaces cannot have fields where as an abstract class can have fields.
  • An interface can inherit from another interface only and cannot inherit from an abstract class, where as an abstract class can inherit from another abstract class or another interface.
  • A class can inherit from multiple interfaces at the same time, where as a class cannot inherit from multiple classes at the same time.
  • Abstract class members can have access modifiers where as interface members cannot have access modifiers.
 
Your Name Your Email-ID
Your Answer