1) What is abstraction? Explain how you have implemented this oops concept in your project? Data abstraction is a process of representing the essential features without including implementation or background details. Example is a bank account. People own savings accounts, checking accounts, credit accounts, investment accounts, but not generic bank accounts. In this case, a bank account can be an abstract class and all the other specialized bank accounts inherit from bank account.
2) What is encapsulation? Explain how you have implemented this oops concept in your project? Encapsulation is a process of binding or wrapping the data and the codes that operates on the data into a single entity. This keeps the data safe from outside interface and misuse. One way to think about encapsulation is as a protective wrapper that prevents code and data from being arbitrarily accessed by other code defined outside the wrapper. Encapsulation means hiding the internal details from other parts of the program. Encapsulation protects an implementation from unintended actions and inadvertent access.
3) Explain Polymorphism with an example on how you have implemented this in your project?
The meaning of Polymorphism is something like one name many forms. Polymorphism enables one entity to be used as as general category for different types of actions. The specific action is determined by the exact nature of the situation. The concept of polymorphism can be explained as "one interface, multiple methods".
4) What are the different types of polymorphism?
There are 2 types of Polymorphism
1. Compile time Polymorphism
2. Run Time Polymorphism
Compile time polymorphism is used for Function overloading
Runtime is used for implementing virtual functions overriding etc.
5)What is an indexer?
Indexers are used for treating an object as an array. The indexers are usually known as smart arrays in C# community. Defining a C# indexer Is much like defining properties. We can say that an indexer is a member that enables an object to be indexed in the same way as an array. this [argument list]
Where the modifier can be private, public,protected or internal. The return type can be any valid C# types. The'this' is a special keyword in C# to indicate the object of the currentclass. The formal-argument-list specifies the parameters of theindexer. The formal parameter list of an indexer corresponds to that ofa method, except that at least one parameter must be specified, andthat the ref and out parameter modifiers are not permitted.Remember that indexers in C# must have at least one parameter. Otherwise the compiler will generate a compilation error.
6) How can you override in derived class?
By default, C# methods are not virtual — if a method is declared as virtual, any class inheriting the method can implement its own version. To make a method virtual, the virtual modifier is used in the method declaration of the base class. The derived class can then override the base virtual method by using the override keyword or hide the virtual method in the base class by using the new keyword. If neither the override keyword nor the new keyword is specified, the compiler will issue a warning and the method in the derived class will hide the method in the base class. C# allows derived classes to contain methods with the same name as base class methods. •
The base class method must be defined virtual.
If the method in the derived class is not preceded by new or override keywords, the compiler will issue a warning and the method will behave as if the new keyword were present. •
If the method in the derived class is preceded with the new keyword, the method is defined as being independent of the method in the base class. •
If the method in the derived class is preceded with the override keyword, objects of the derived class will call that method rather than the base...
Please join StudyMode to read the full document