Hai ra

oops concept in .net interview questions and answers, object oriented programming coneps in .net

 oops concept in .net interview  questions and answers, object oriented programming coneps in .net

 Hi welcome Back to Dotnet section today i would like to share more .net interview questions and answers on Topic oops.
oops, oops concept

1). what are the  different types of inheritance.
Inheritance in OOP is of four types:
  • Single inheritance - Contains one base class , one derived class
  • Hierarchical inheritance - Contains one base class and the multiple derived classes of the same base class
  • Multilevel inheritance - Contains a class derived from the derived class
  • Multiple inheritance - Contains several base classes and the derived class

2)What do you mean by term data encapsulation?
Data encapsulation is a concept of binding data and code in single unit called object and hiding all implementation details of a class from the user. It prevents unauthorized access of data and restricts user to use the necessary data only.
3). What is the difference between procedural and object-oriented programming Explian?
Procedural programming is based upon  modular approach in which the larger programs are broken into procedures. Each procedure is a set of instructions that are executed one after another. whereas  OOP is based upon the objects. An object consists of various elements such as methods and variables.
And morever Access modifiers are not used in procedural programming, which implies that the entire data can be accessed freely anywhere in the program. In OOP, you can specify the scope of a particular data by using access modifiers - public, private, internal, protected, and protected internal.


49. What are different ways  method can be overloaded?
The different ways to overload a method are  as follows:
  • By changing  number of parameters used
  • By changing  order of parameters
  • By using different data types for  parameters
4. Give the difference  between an abstract class and an interface.
Abstract Class:
  1. class can extend only one abstract class
  2.  members of abstract class can be private as well as protected.
  3. Abstract classes should have the  subclasses
  4. Any class can extend from an abstract class.
  5. Methods in  a abstract class can be abstract as well as concrete.
  6. There can be a constructor for the abstract class.
  7. The class extending abstract class may or may not implement any of its method.
  8.  abstract class can implement methods.

Interface
  1. class can implement several interfaces
  2. An interface can only have the  public members.
  3. Interfaces must have implementations by classes
  4. Only an interface can extend from another interface.
  5. All methods in an interface should be abstract
  6. Interface does not have a constructor.
  7. All methods of interface need to be implemented by a class implementing that interface.
  8. Interfaces cannot contain body of  th eany of its method. 
5. When do you really need to create an abstract class explain?
We define abstract classes when we define the  template that needs to be followed by all  derived classes.



Previous
Next Post »