In: Computer Science
Questions related to C#.
When you build a class in C#.NET, how many sub classes can inherit from the class that you just built?
In Object Oriented Development, there are 3 primary concepts that define Object Oriented Programming. What are these concepts?
Function/Method Overloading is when you build 2 or 3 functions with the same name but different argument lists. T/F?
1. When you build a class, if it is the base class, it is also calles super class.It is the ancestorial class. All the other class are derived from the base class.
A super class can have any number of subclass.While comming to iherritance, the single inherritance the class have only one subclass, but as we go further to multilevel or multiple inherritance, a class can have many sub classes. But a subclass should only have one super class.
2. Three primary Concepts of OOP
The three primary concepts of Object Oriented Programming are :
Encapsulation
Encapsulation is nothing but wrapping up of data or functions into a single unit.The unit contains large processings or functions.But they are shown as a single entity.
eg : A Calculator
Inherritance
Inheritance is a mechanism in which one class acquires the property of another class. For example, a child inherits the traits of his/her parents. With inheritance, we can reuse the fields and methods of the existing class.
eg : Ancestorial inherritance
Polymorphism
Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object.
eg : you have a smartphone for communication. The communication mode you choose could be anything. It can be a call, a text message, a picture message, mail, etc. So, the goal is common that is communication, but their approach is different. This is called Polymorphism.
3. TRUE , Function Overloading is nothing but the function with same name but different argument or parameters.
An example in C is :
int Volume(int s)
{
return s * s * s;
}
double Volume(double r, int h)
{
return 3.1415926 * r * r * static_cast<double>(h);
}
long Volume(long l, int b, int h)
{
return l * b * h;
}
In the above example, all the functions have the same name volume, but the parameters are different.