1. 程式人生 > >C#語言和SQL Server資料庫技術_前四章錯題

C#語言和SQL Server資料庫技術_前四章錯題

 

1。在C#中,如果讓某個方法只能被它所在的程式集內的其他方法訪問,可使用(C)修飾這個方法。

(選擇一項)

A:private

B:protected

C:internal

D:以上都不對

2.下列關於String.Format()用法不正確的是(B)

(選擇一項)

A:String.Format(“今天是周{0}”,1)

B:String.Format(“今天是周{1}”,1)

C:String a= "a"; String.Format(“我的姓名是{0}”,a)

D:String.Format(“今天是周{0}”,"a")

3.在C#中,如下程式碼的輸出結果是()

string str=",(9,8),(aa,bb),";

string array=str.Substring(str.IndexOf(',')+1,str.LastIndexOf(','));

ine(array);

(選擇一項)

A:(9,8),(aa,bb)

B:(9,8),(aa,bb),

C:9,8),(aa,bb),

D:9,8),(aa,bb)

4.多數程式語言都提供陣列這種資料儲存結構來儲存同種型別的多個數據元素。在C#中定義瞭如下陣列。選項中有關該陣列的說法中錯誤的是(B)。

int [] array;

array=new int[10];

(選擇一項)

A:該陣列最多包含10個元素

B:該陣列的第一個陣列元素索引值為1

C:該陣列各元素已被賦了預設值0

D:該陣列定義與int [] array=new int [10];等價

5.C#迴圈語句中break的作用是(B,D)。

(選擇兩項)

A:break後面的語句繼續執行

B:break後面的語句不執行

C:用於退出當次迴圈

D:用於終止本迴圈語句的執行

6.下面選項中對C#註釋使用錯誤的是(C,D)。

(選擇兩項)

A://這是單行註釋

B:/*這是多行註釋*/

C://*這是文件註釋*/

D:///這才是文件註釋\\\

7.執行如下C#程式碼,輸出(D)。

int num1=7;

int num2=9;

double avg=num1+num2/2.0;

Console,WriteLine(avg);

(選這一項)

A:8

B:8.0

C:11.0

D:11.5

8.使用C#語言開發控制檯應用程式時,如果程式將使用者輸入的資料(可能是字串或整型數字)賦值給一個字串變數,則可以使用以下(A,B)程式碼片段實現。

(選擇兩項)

A:string s=Console.ReadLine().ToString();

B:string s=Console.ReadLine(0;

C:string s=Console.WriteLine().ToString();

D:string s=Console.WriteLine();

9.在C#中,已定義Student類,下面程式碼能編譯通過的是(A,B)。

public class Student

{

  public void Show()

  {

    Console.WriteLine("大家好");

  }

}

(選擇兩項)

A:

class Program

{

  static void Main(string[] args)

 {

    Student stu=null;

    stu.Show();

    Console.ReadLine();

  }

}

B:

class Program

{

  static void Main(string[] args)

 {

    Student stu=new Student();

    stu.Show();

    Console.ReadLine();

  }

}

C:

class Program

{

  static void Main(string[] args)

 {

    Student stu;

    stu.Show();

    Console.ReadLine();

  }

}

D:

class Program

{

  static void Main(string[] args)

 {

    Student stu=new Student;

    stu.Show();

    Console.ReadLine();

  }

}

10.用Visual Studio除錯C#程式,以下說法正確的是(A,C)

(選擇兩項)

A:將游標停在需要設定斷點的行,按F9鍵,可以設定斷點

B:Ctrl+F2鍵轉到所呼叫過程過程或變數的定義

C:F5鍵開始除錯

D:Ctrl+F10鍵取消斷點

11.執行下面的C#程式碼,輸出的結果是(B)。

static void Mian(string[] args)

{

  int[] nums={1,2,3,4};

  TrunCate(nums);

  Console.WriteLine(nums[1]);

}

static void TrunCate(int[] nums)

{

  nums[1]=99;

}

(選擇一項)

A:2

B:99

C:1

D:編譯出現語法錯誤,不能執行

1。在C#中,如果讓某個方法只能被它所在的程式集內的其他方法訪問,可使用(C)修飾這個方法。

(選擇一項)

A:private

B:protected

C:internal

D:以上都不對

2.下列關於String.Format()用法不正確的是(B)

(選擇一項)

A:String.Format(“今天是周{0}”,1)

B:String.Format(“今天是周{1}”,1)

C:String a= "a"; String.Format(“我的姓名是{0}”,a)

D:String.Format(“今天是周{0}”,"a")

3.在C#中,如下程式碼的輸出結果是()

string str=",(9,8),(aa,bb),";

string array=str.Substring(str.IndexOf(',')+1,str.LastIndexOf(','));

ine(array);

(選擇一項)

A:(9,8),(aa,bb)

B:(9,8),(aa,bb),

C:9,8),(aa,bb),

D:9,8),(aa,bb)

4.多數程式語言都提供陣列這種資料儲存結構來儲存同種型別的多個數據元素。在C#中定義瞭如下陣列。選項中有關該陣列的說法中錯誤的是(B)。

int [] array;

array=new int[10];

(選擇一項)

A:該陣列最多包含10個元素

B:該陣列的第一個陣列元素索引值為1

C:該陣列各元素已被賦了預設值0

D:該陣列定義與int [] array=new int [10];等價

5.C#迴圈語句中break的作用是(B,D)。

(選擇兩項)

A:break後面的語句繼續執行

B:break後面的語句不執行

C:用於退出當次迴圈

D:用於終止本迴圈語句的執行

6.下面選項中對C#註釋使用錯誤的是(C,D)。

(選擇兩項)

A://這是單行註釋

B:/*這是多行註釋*/

C://*這是文件註釋*/

D:///這才是文件註釋\\\

7.執行如下C#程式碼,輸出(D)。

int num1=7;

int num2=9;

double avg=num1+num2/2.0;

Console,WriteLine(avg);

(選這一項)

A:8

B:8.0

C:11.0

D:11.5

8.使用C#語言開發控制檯應用程式時,如果程式將使用者輸入的資料(可能是字串或整型數字)賦值給一個字串變數,則可以使用以下(A,B)程式碼片段實現。

(選擇兩項)

A:string s=Console.ReadLine().ToString();

B:string s=Console.ReadLine(0;

C:string s=Console.WriteLine().ToString();

D:string s=Console.WriteLine();

9.在C#中,已定義Student類,下面程式碼能編譯通過的是(A,B)。

public class Student

{

  public void Show()

  {

    Console.WriteLine("大家好");

  }

}

(選擇兩項)

A:

class Program

{

  static void Main(string[] args)

 {

    Student stu=null;

    stu.Show();

    Console.ReadLine();

  }

}

B:

class Program

{

  static void Main(string[] args)

 {

    Student stu=new Student();

    stu.Show();

    Console.ReadLine();

  }

}

C:

class Program

{

  static void Main(string[] args)

 {

    Student stu;

    stu.Show();

    Console.ReadLine();

  }

}

D:

class Program

{

  static void Main(string[] args)

 {

    Student stu=new Student;

    stu.Show();

    Console.ReadLine();

  }

}

10.用Visual Studio除錯C#程式,以下說法正確的是(A,C)

(選擇兩項)

A:將游標停在需要設定斷點的行,按F9鍵,可以設定斷點

B:Ctrl+F2鍵轉到所呼叫過程過程或變數的定義

C:F5鍵開始除錯

D:Ctrl+F10鍵取消斷點

11.執行下面的C#程式碼,輸出的結果是(B)。

static void Mian(string[] args)

{

  int[] nums={1,2,3,4};

  TrunCate(nums);

  Console.WriteLine(nums[1]);

}

static void TrunCate(int[] nums)

{

  nums[1]=99;

}

(選擇一項)

A:2

B:99

C:1

D:編譯出現語法錯誤,不能執行