C # quiz
If you can answer the following questions correctly, you can be invincible in the face of any C # interview pen questions. Of course, this is much easier than C ++'s abnormal questions. For the correct answer, compile and run it. Good luck.
1. What is the problem with the following code?
Public Class B
{
Protected virtual void F () {console. writeline ("B ");}
}
Public Class D: B
{
Protected override void F () {console. writeline ("D ");}
Public void g (B)
{
B. F ();
}
Static void main ()
{
D = new D ();
D. G (d );
}
}
2. What are the effects of the following code?
Interface iincrementable
{
Void increment ();
}
Struct quadword: iincrementable
{
Long value;
Public void increment () {value ++ ;}
Public Static Implicit operator long (quadword q) {return Q. value ;}
}
Static class Program
{
Static void F (iincrementable Inc, int count)
{
For (INT I = 0; I <count; I ++)
Inc. increment ();
}
Static void main ()
{
Quadword q = new quadword ();
F (Q, 100 );
Console. writeline (Q );
}
}
3. What are the effects of the following code?
Class C1
{
Public static readonly int A = (INT) math. Round (math. Pi );
Public static readonly int B = c2.a;
}
Class C2
{
Public static readonly int A = c1.a;
}
Class Program
{
Static void main ()
{
Console. writeline (c1. B );
}
}