Access Specifier

_ Desc Defaults
Public Accessable even outside the namespace interface, enum
Private Only on same class method, constructor
Protected Accessed in child class and helps inheritance
Internal Within application top levelclass, delegate, interface
Protected Internal Same assembly, or any derived class different assembly. (protected or internal)

Can you declare a private class in a namespace?

The classes in a namespace are internal, by default.

However, you can explicitly declare them as public and not as private, protected, or protected internal. The nested classes can be declared as private,protected, or protected internal.

Why use Get Set Modifier

The get set accessor or modifier mostly used for storing and retrieving value from the private field. The get must return a value of property type where as set returns void.

In simple word, the get method used for retrieving value from private field whereas set method used for storing value in private variables.

What is Static Constructor

When we declared static constructor it will be invoked only once for any number of instances. Static constructor is used to initialize static fields of the class and to write the code that needs to be executed only once.

Can a private virtual method be overridden?

No, CLR with not allow private in virtual method

What is enum

An enumeration is a set of named integer constants. An enumerated type is declared using the enum keyword.

enum Importance {
 None,
 Trivial,
 Regular,
 Important,
 Critical
};

Some True Statement

  1. Override method is used to provide implementation of abstract method
  2. We cannot use static or virtual modifiers to declare abstract methods.
  3. Declaration of abstract methods is limited only to the abstract class
  4. Abstract classes can be inherited in derived classes
  5. Abstract classes can not be instantiated
  6. Abstract classes can contain both definition and body
  7. all the members, properties, methods defined inside it must be declared static.
  8. static class constructors must be private
  9. members, properties and methods are accessed with static class name
  10. sealed classes can be instantiated
  11. sealed keyword is used for declaring class
  12. sealed classes are used to restrict the inheritace feature of oop
  13. sealed classes are primarily used to prevent derivation

results matching ""

    No results matching ""