I saw a quiz (http://blog.joycode.com/ninputer/archive/2005/11/02/66256.aspx) about the C #2.0 Model in the blog Hall, considering JDK 5.0 has also introduced the model, the purpose of JDK 5.0 to do the corresponding test.
Quiz1:
Determine whether the following code is correct. If there is a mistake, the error type is indicated. If there is no error, the output result is indicated.
Public class genericquiz1
{
Public static void main (string [] ARGs)
{
A <integer> A = new A <integer> ();
A. internalcall (2005 );
}
}
Class A <t>
{
Void internalcall (t p)
{
Test (P );
}
Void test (t p)
{
System. Out. println ("use t ");
}
Void test (integer p)
{
System. Out. println ("use integer ");
}
}
Quiz2:
Determine whether the following code is correct. If there is a mistake, the error type is indicated. If there is no error, the output result is indicated.
Public class genericquiz1
{
Public static void main (string [] ARGs)
{
A <integer> A = new A <integer> ();
A. Test (2005 );
}
}
Class A <t>
{
Void test (t p)
{
System. Out. println ("use t ");
}
Void test (int p)
{
System. Out. println ("use int ");
}
}
Quiz3:
Determine whether the following code is correct. If there is a mistake, the error type is indicated. If there is no error, the output result is indicated.
Public class genericquiz1
{
Public static void main (string [] ARGs)
{
A <integer> A = new A <integer> ();
A. Test (2005 );
}
}
Class A <t>
{
Void test (t p)
{
System. Out. println ("use t ");
}
Void test (integer p)
{
System. Out. println ("use integer ");
}
}
Quiz4:
Determine whether the following code is correct. If there is a mistake, the error type is indicated. If there is no error, the output result is indicated.
Public class genericquiz1
{
Public static void main (string [] ARGs)
{
A <integer> A = new A <integer> ();
A. Test (2005 );
}
}
Class A <t>
{
Void test (t p)
{
System. Out. println ("use t ");
}
<U> void test (u p)
{
System. Out. println ("use U ");
}
}