c#questions and answers

c# interview questions and Answers

1.When call by value, call by reference, call by out?

 
 CALL BY VALUE:
Whenever we want to pass some value to a function. The modifications are not expecting to reflect back. To actual parameter then we will pass it as CALL BY VALUE.
 
CALL BY REFERENCE:
Whenever we want to pass some value and we are expecting the modifications. Should be reflected back to actual parameter then we will pass it as CALL BY REFERENCE.
 
CALL BY OUT:
Whenever we don’t want to pass any values but we are expecting back the modifications. then we will pass the particular parameter as CALL BY OUT.
 
2. What is Encapsulation? How can we achieve?
 
A) Wrapping STATES and BEHAVIOURS called as ENCAPSULATION. (Or) Binding VARIABLES and METHODS called as ENCAPSULATION. By implementing class we can achieve ENCAPSULATION.
 
3. What is abstraction? How can we achieve?
 
Abstraction means HIDING.
 
Abstractions are 2 types.
 
1) data abstraction:-
 
Hiding unwanted data called as data abstraction
 
2) Method abstraction:-
 
Invoking required method and hiding unwanted method called as method abstraction.
 
With the help of FUNCTION OVERLOADING, we can achieve Method ABSTRACTION.
 
4. What is Inheritance? Types of Inheritance?
 
Inheriting or deriving members from one class. To another class called as INHERITANCE.
 
C#.Net will support 5 types of Inheritance. They are
  • Single Inheritance 
  • Multi-level Inheritance 
  • Many Inheritance 
  • Hierarchical Inheritance 
  • Hybrid Inheritance.
 5. Is C#.Net will support much Inheritance?
 
In C#.NET many inheritances are not possible by using classes. which is possible with the help of INTERFACES.
 
6. What sealed class? When will we go for sealed class?
 
While characterizing a class, in the event that we have utilized ―sealed‖ watchword. Then that class can be called as SEALED CLASS. It can't be acquired.
 
At whatever point we need to confine to get a class we can go for fixed class.
 
7.Why property?
 
  • To assign the value to a class level variable. After creating the object to retrieve the value from the class level variable  
  • The property will provide SECURITY to variable data.  
  • The property will provide VALIDATION FACILITY for variable data. At the time of Assigning.
 
8. What is static polymorphism and dynamic polymorphism?
 
A) STATIC POLYMORPHISM:
 
A method which will bind at compile time will execute. In runtime called as static polymorphism or early binding or compile time polymorphism
 
DYNAMIC POLYMORPHISM:
 
A method which will bind at compile time will not execute, instead of that a method. which will bind at runtime will execute called as RUNTIME POLYMORPHISM.
 
9. What is function overloading? When will we go for function overloading?
 
A) FUNCTION OVERLOADING: Having many methods with the same name but a different no. of arguments or the different type of arguments or different order of arguments. In a single class or in a combination of base and derived class.
 
WHEN: Whenever we want to install the same method with the different functionalities. Then we have to go for FUNCTION OVERLOADING
 
10.Difference between constructor and property?
 
Constructor
 
It used to initialize the instance variables at the time of creating an object.
 
PROPERTY
 
It used to assign the value to the class level variables as well as can retrieve the value from class level variables
 

For more Dot net interview questions: click here

Dot training in Hyderabad: 

Kosmik provides dot net training in Hyderabad. we are providing lab facilities with complete real-time training and training based on advanced concepts.