Professional Documents
Culture Documents
======================================================================
Q)what is virtual method?
virtual method must decoarate with virtual keyword
virtual method is eligible to override
Q)is it manadatory to overridie virtual method?
Overriding virtual method is optional in Derived class
Q)what is the difference between abstract method and virtual Method?
abstract method virtual method
1. abstract method must declare with 1. virtual method must declare with
virtual
abstract keyword keyword
2. abstract method is unimplemented 2. virtual method is implemented method
method
3. it is manadatory to override 3. overriding virtual method is
optional in
abstract method derived class
================================================
Q)what is Upcasting?
subclass object assigned to super class Reference
in the scenario where single parent and multiple child exist then reference is
fixed
i.e reference is created for super class and object was created for sub class
class RBI
{
public virtual void ROI()
{
ROI is 3/-
}
}
class ICICI:RBI class Axis:RBI class SBI:RBI
{ { {
public override void ROI() public override void ROI()
{ {
ROI is 5/- ROI is 7/-
} }
} } }
RBI rb=new ------();
---- may be ICICI,Axis,SBI
rb.ROI();
in appn development if single parent and multiple child exist then object was
created
for derived class by server,CLR,Container and that object was assigned to super
class
Reference
Q)what is Compiletime Polymorphism?
Method call will bind with Method Behavior at compiletime i.e which method
will gets executed was decided at compiletime
we can achive Compiletime Polymorphism by using Overloading
Q)what is Runtime Polymorphism?
Method call will bind with Method Behavior at Runtime
i.e which method will gets executed was decided at runtime based on the object
creation