Original article: http://elwin.blogchina.com/blog/article_84602.1080323.html
Name: Date:
1. Fill in the blanks: (1) the object-oriented languages include ________, _________, and.
(2) The type of the ____________ interface or the declared ____________ method must be implemented for objects that can be accessed through foreach traversal.
(3) list the five main objects in ado.net _______________,_____________,_______________,_______________,_________________.
2. optional items:
(1) which of the following statements are true:
A. The interface can contain virtual methods. B. A class can implement multiple interfaces.
C. The interface cannot be instantiated. D. The interface can contain implemented methods.
(2) You may use the following methods to read records from the database:
A. executenonquery B. executescalar
C. Fill D. executereader
3. Briefly describe the access permissions of private, protected, public, and internal modifiers.
4. Write an SQL statement: extract the 31st to 40th records in Table A (sqlserver, using the Automatically increasing ID as the primary key. Note: The ID may not be consecutive .)
5. list several methods for passing values between ASP. NET pages.
6. Write the output result of the program
Class class1 {
Private string STR = "class1.str ";
Private int I = 0;
Static void stringconvert (string Str ){
STR = "string being converted .";
}
Static void stringconvert (class1 c ){
C. Str = "string being converted .";
}
Static void add (int I ){
I ++;
}
Static void addwithref (ref int I ){
I ++;
}
Static void main (){
Int I1 = 10;
Int I2 = 20;
String STR = "str ";
Class1 c = new class1 ();
Add (I1 );
Addwithref (ref I2 );
Add (C. I );
Stringconvert (STR );
Stringconvert (C );
Console. writeline (I1 );
Console. writeline (I2 );
Console. writeline (C. I );
Console. writeline (STR );
Console. writeline (C. Str );
}
}
7. Write the output result of the program
Public abstract class
{
Public ()
{
Console. writeline ('A ');
}
Public Virtual void fun ()
{
Console. writeline ("A. Fun ()");
}
}
Public Class B:
{
Public B ()
{
Console. writeline ('B ');
}
Public new void fun ()
{
Console. writeline ("B. Fun ()");
}
Public static void main ()
{
A A = new B ();
A. Fun ();
}
}
8. Write the output result of the program:
Public Class
{
Public Virtual void fun1 (int I)
{
Console. writeline (I );
}
Public void fun2 ()
{
A. fun1 (1 );
Fun1 (5 );
}
}
Public Class B:
{
Public override void fun1 (int I)
{
Base. fun1 (I + 1 );
}
Public static void main ()
{
B = new B ();
A A = new ();
A. fun2 (B );
B. fun2 ();
}
}
9. The rules for columns are as follows: 1, 1, 2, 3, 5, 8, 13, 21, 34 ......
Calculate the number of 30th digits and use a recursive algorithm. (C # language)
10. Program Design: when the cat shouted, all the mice started to escape and the host was awakened. (C # language)
Requirement: 1. The interaction between the mouse and the host must be active.
2. Considering scalability, the call of a cat may cause other association effects.
Reference answer:
1. (1) Inheritance, encapsulation, and polymorphism. (Basic concepts)
(2) ienumerable and getenumerator)
(3)... (score assignment, understanding of ado.net)
Scoring standard: 1 out of 1, out of 10.
2. (1) B, c (understanding of interfaces) (2) B, C, and D (test the proficiency of ado.net)
Scoring standard: five points for a question. If you do not select a question or make an incorrect choice, no score is obtained. The missing score is 2 points. Out of 10.
3. Private: Private member, which can be accessed within the class.
Protected: protects members, which can be accessed within the class and in the inheritance class.
Public: A Public member. It is completely public and has no access restrictions.
Internal: accessible within the same namespace.
Scoring standard: Correct question: 2 points, 2 questions: 5 points, 3 questions: 7 points. 10 points for all. (Score assignment)
4. solution 1: Select top 10 * from a where id not in (select top 30 ID from)
Solution 2: Select top 10 * from a where ID> (select max (ID) from (select top 30 ID from a) as)
Scoring standard: Write-to-Peer score: 10 points. (The answer is not unique, and the DataGrid page may be used)
5. 1. Use querystring, such ....? Id = 1; response. Redirect ()....
2. Use session Variables
3. Use server. Transfer
....
Scoring standard: You get 3 points for the correct answer at 02:07, 03:10.
6. (test value reference and Object Reference)
10
21
0
Str
String being converted.
Scoring standard: 2 points for correct answers, out of 10 points.
7.
B
A. Fun ()
Rating criteria: Write A. B for 5 points, write a. Fun () for 5 points, out of 10 points.
(Test the constructor in the inheritance class and the new method ,)
8. 2
5
1
6
Scoring standard: 2 points for correct answers, 5 points for two points, and 7 points for three points. 10 points for all.
(Some people are dizzy with this question... ^_^)
9.
Public class mainclass
{
Public static void main ()
{
Console. writeline (FOO (30 ));
}
Public static int Foo (int I)
{
If (I <= 0)
Return 0;
Else if (I> 0 & I <= 2)
Return 1;
Else return Foo (I-1) + Foo (I-2 );
}
}
Rating criteria: Write return Foo (I-1) + Foo (I-2); 5 points.
Write if (I> 0 & I <= 2) return 1; 5 points.
Too many method parameters need to be deducted (deduct score = number of parameters-1)
Deduct 5 points without Recursive Algorithms
(Recursive algorithms are commonly used in tree structures)
10
Key points: 1. linkage effect. To run the code, you only need to execute the cat. cryed () method. 2. abstract the mouse and the host
Scoring standard: <1>. constructs cat, mouse, and master classes, and enables the program to run (2 points)
<2> extract abstraction from mouse and master (5 points)
<3> As long as Cat. cryed () is executed, the mouse can escape and the host will be awakened. (3 points)
Public interface observer
{
Void response (); // the response of the observer, if the mouse sees the reflection of the cat
}
Public interface subject
{
Void aimat (Observer obs); // for which observers, this refers to the object to be captured by a cat-Mouse
}
Public class mouse: Observer
{
Private string name;
Public mouse (string name, subject subj)
{
This. Name = Name;
Subj. aimat (this );
}
Public void response ()
{
Console. writeline (name + "attempt to escape! ");
}
}
Public class master: Observer
{
Public master (subject subj)
{
Subj. aimat (this );
}
Public void response ()
{
Console. writeline ("host waken! ");
}
}
Public class Cat: Subject
{
Private arraylist observers;
Public CAT ()
{
This. Observers = new arraylist ();
}
Public void aimat (Observer obs)
{
This. Observers. Add (OBS );
}
Public void cry ()
{
Console. writeline ("cat cryed! ");
Foreach (Observer OBS in this. Observers)
{
Obs. Response ();
}
}
}
Class mainclass
{
Static void main (string [] ARGs)
{
Cat cat = new CAT ();
Mouse mouse1 = new mouse ("mouse1", CAT );
Mouse mouse2 = new mouse ("mouse2", CAT );
Master = new master (CAT );
Cat. Cry ();
}
}
// Configure //---------------------------------------------------------------------------------------------
Design Method 2: Design with event -- delegate ..
Public Delegate void subeventhandler ();
Public abstract class subject
{
Public event subeventhandler subevent;
Protected void fireaway ()
{
If (this. subevent! = NULL)
This. subevent ();
}
}
Public class Cat: Subject
{
Public void cry ()
{
Console. writeline ("cat cryed .");
This. fireaway ();
}
}
Public abstract class observer
{
Public observer (subject sub)
{
Sub. subevent + = new subeventhandler (response );
}
Public abstract void response ();
}
Public class mouse: Observer
{
Private string name;
Public mouse (string name, subject sub): Base (sub)
{
This. Name = Name;
}
Public override void response ()
{
Console. writeline (name + "attempt to escape! ");
}
}
Public class master: Observer
{
Public master (subject sub): Base (sub ){}
Public override void response ()
{
Console. writeline ("host waken ");
}
}
Class class1
{
Static void main (string [] ARGs)
{
Cat cat = new CAT ();
Mouse mouse1 = new mouse ("mouse1", CAT );
Mouse mouse2 = new mouse ("mouse2", CAT );
Master = new master (CAT );
Cat. Cry ();
}
}