Basics Flashcards
(++, – ) What are these operators called?
Unary
How do you use a goto?
Make a label of any name, e.g. “label:”, then use goto label.
How would you pass a reference type in a method argument?
ref <property> <property></property></property>
When is a constructor invoked?
At the time of object creation.
How would you create a Destructor?
~ClassName() { }
What is static?
A keyword or modifier that belongs to the type and not instance. Instance is not required to access static members.
What are the benefits of using static?
Memory efficient as we don’t need to create instances to access their members.
What is inheritance?
The process in which one object acquires all the properties and behaviours of its parent object automatically
What is the advantage of inheritance?
Code reusability: Now you can reuse the members of your parent class. So, there is no need to define the member again. So less code is required in the class.
What are the two types of polymorphism?
Compile time polymorphism and runtime polymorphism
How is compile time polymorphism achieved?
Compile time polymorphism is achieved by method overloading and operator overloading in C#
How is runtime polymorphism achieved?
Having a derived class defining the same method as defined in its base class.
What is method overloading?
Having two methods of the same name with different params or different param types.
What is method overriding?
If derived class defines same method as defined in its base class, it is known as method overriding in C#
What is polymorphism?
Having a single entity have multiple implementations.