Saturday 15 May 2010

Technical Questions part 1

1. What is Object Oriented Programming?
Object-oriented programming (OOP) is a programming paradigm that uses "objects" – data structures consisting of datafields and methods together with their interactions – to design applications and computer programs.

2. What are the main principals of OOP?
Programming techniques may include features such as data abstraction, encapsulation, modularity, polymorphism, and inheritance.

3. What is the difference between a Value Type and a Reference Type?
Variables that are based on value types directly contain values. Assigning one value type variable to another copies the contained value. This differs from the assignment of reference type variables, which copies a reference to the object but not the object itself.

Unlike with reference types, you cannot derive a new type from a value type. However, like reference types, structs can implement interfaces.

Unlike reference types, a value type cannot contain the null value. However, the nullable types feature does allow for values types to be assigned to null.

Each value type has an implicit default constructor that initializes the default value of that type.

4. What is an Abstract Class?
An abstract class cannot be instantiated. The purpose of an abstract class is to provide a common definition of a base class that multiple derived classes can share. For example, a class library may define an abstract class that is used as a parameter to many of its functions, and require programmers using that library to provide their own implementation of the class by creating a derived class.

5. What is an Interface?
An interface has the following properties:
• An interface is like an abstract base class: any non-abstract type inheriting the interface must implement all its members.
• An interface cannot be instantiated directly.
• Interfaces can contain events, indexers, methods and properties.
• Interfaces contain no implementation of methods.
• Classes and structs can inherit from more than one interface.
• An interface can itself inherit from multiple interfaces.

6. What is Inheritance?
A class that derives from another class (the base class) automatically contains all the public, protected, and internal members of the base class except its constructors and destructors.

7. Does C# allow for multiple Inheritances?
No

8. What is Encapsulation?
According to the principle of encapsulation, a class or struct can specify how accessible each of its members is to code outside of the class or struct. Methods and variables that are not intended to be used from outside of the class or assembly can be hidden to limit the potential for coding errors or malicious exploits.

9. Name the access modifiers in C#.
It is important to limit the accessibility of your code so that only the intended client code can reach it. You specify how accessible your types and their members are to client code by using the access modifiers:

a. public
The type or member can be accessed by any other code in the same assembly or another assembly that references it.

b. private
The type or member can only be accessed by code in the same class or struct.

c. protected
The type or member can only be accessed by code in the same class or struct, or in a derived class.

d. internal
The type or member can be accessed by any code in the same assembly, but not from another assembly.

e. protected internal
The type or member can be accessed by any code in the same assembly, or by any derived class in another assembly.

No comments:

Post a Comment