Skip to content

Instantly share code, notes, and snippets.

@rozer007
Created November 24, 2021 05:35
Show Gist options
  • Save rozer007/5ede582ab239fece810f522c85f0f9b1 to your computer and use it in GitHub Desktop.
Save rozer007/5ede582ab239fece810f522c85f0f9b1 to your computer and use it in GitHub Desktop.
Inheritanec in c#
1. What is the need of inheritance?
Ans- We use inheritance because it provides us code reusability and reduces our code. It also reduces data redundancy and duplicacy.
2. Does C# supoorts multiple inheritance?
Ans- No C# only doesn't support multiple inheritance but we can use modules to implement multiple inheritance.
3. How can we create a method to override the method in base class
ans: we will use the new keyword use the function name while declaring a function for overriding.
4. How can we called the superclass constructor in a base class.
ans: We will use base() function to called the constructor of the base class
eg. constructor():base()
1. Which symbol is used to inherit a class in c#?
a. extends
b. :
c. <
d. None of the above
Ans b
2. C# supports multiple class inheritance?
a. True
b. False
Ans b
3. We can overwrite parent class methods in our child class?
a. True
b. False
Ans a
4.What is called as the data hiding ?
a. method overloading
b. inheritance
c. method overriding
d. none of the above
ans c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment