Home | | C Sharp and .NET Framework(CNF) | Important Short Questions and Answers: C# OOPS

Chapter: C# and .NET Framework

Important Short Questions and Answers: C# OOPS

C# and .NET Framework - Important Short Questions and Answers: C# OOPS

1. What is a constructor?


A constructor initializes an object when it is created. It has the same name as its class and is syntactically similar to a method. However, constructor have no explicit return type. The general form of constructor if shown here:


Access class-name()



//constructor code



2. What is a static constructor?


A static constructor is called before any object of the class is created. This is useful to do any housekeeping work that needs to be done once. it is usually used to assign initial values to static data members.


3. What are the restrictions of static methods?


That there is no access modifier on static constructors. It cannot take any. A class can have only one static constructor.


4. What is property?



Another type of class members is the property. A property combines a field with the methods that access it. if you want to create a field that is available to users of an objects, but you want to maintain control over the operations allowed on that field.


5. What is read-only property?


There are situations where we would like to decide the value of a constant member at run- time. We may also like to have different constant values for different objects of the class. To overcome these shortcomings, c# provides another modifier known as read only


6. What is an indexer?


Array indexing is performed using the []operator. An indexer allows an object to be indexed like an array. The main use of indexes is to support the creation of specified arrays that are subjects to one or more constraints.


7. What are the two form of inheritance?

The two form of inheritance classical form, containment form


8. What is hiding a method?


We can use the modifier new to tell the compiler that the derived class method ―hides‖ the base class method.


9. What is polymorphism?


Polymorphism means ’one name, many form’. Polymorphism can be achieved in two ways. c# supports both of them


·        Operation polymorphism

·        Inclusion polymorphism


10.What is early binding?

The compiler is  able to select  and bind the appropriate method to the object for a


particular call at complier time itself. this process is called early binding, or static binding ,it is also known as complier time polymorphism


11. What is late binding?


The decision on exactly which method to call is delayed until runtime and, therefore, it is also known as runtime polymorphism. Since the method is linking with a particular class much later after compilation, this process is termed late binding.


12. What is operator overloading?


This means, c# has the ability to provide the operator with a special meaning for data type .this mechanism of giving such special meaning to an operator is known as operator overloading.


13. List the operators that can be overloaded?

Category          Operations


Binary arithmetic +,*,?,-,%

Unary arithmetic  +,-,++,--


Binary bitwise      &,|,^,<<,>>

Unary bitwise      !,~,true, false


14.     List the operators that cannot be overloaded?

          Category     Operations

          Conditional operators    &&,||

          Compound assignment  +=,-=,*=,/=,%=

15.     What is a delegate?


The dictionary meaning of delegate is ―a person acting for another person‖. In c#, it really means method acting for another method. Creating and using delegates involves four steps. They include:


·        Delegate declaration

·        Delegate methods definition

·        Delegate instantiation

·        Delegate invocation


16.            What delegate method?


Delegate methods are any functions (defined in a class) whose signature matches the declare signature matches the delegate signature exactly.


17. What is multicast delegate?


It is possible for certain delete to hold and invoke multiple methods. Such delegates are called multicast delegates. Multicast delegates, also known as combinable delegates, must satisfy the following conditions:


·        The return types of the delegate must be void.


·        None of the parameter of the delegate type can be declared as out put parameter, using out keyword.


18.          What is an event?


An event is a delegate type class member that is used by the objects or class to provide a notification to other objects that event has occurred. The client object can act on an event by adding an event handler to the event


19. What is an interface?


An interface can contain one or more methods, properties, indexers and events but none of them are implemented in the interface itself. It is the responsibility of the class that implements to define the code for implementation of theses members.


20. What is the purpose of using the finally block?


C# supports another statements known as a finally statements that can be used to handle an exception that is not caught by any of the previous catch statements. A finally blocks can be used to handle any exception generated within a try block.



Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
C# and .NET Framework : Important Short Questions and Answers: C# OOPS |

Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.