OOPs Interview Questions

Question : State whether below overload methods will give compilation error or not ?

Question : State whether below overload methods will give compilation error or not ?

Class Test

{

void SetX(ref int x)

{

x = 1;

}

void SetX(out int x)

{

X = 2;

}

}

Answer :

Gives a compilation error.

SetX method cannot define overloaded methods that differ only on ref and out

Leave a Reply