{
get {
return this.age; } set {
if(value > 0 && value <= 100) {
this.age = value; } } }
public Student(int age) {
this.age = age; } }
a) 10
100 b) 105
100 c) 100
105 d) 10
105
65、在C#中,下列代码的运行结果是( D )。
using System;
public class TEApp {
public static void ThrowException() {
throw new Exception(); }
public static void Main() {
try {
ThrowException();
Console.WriteLine(\); }
catch(Exception err) {
Console.WriteLine(\); }
finally {
Console.WriteLine(\); } } }
a) b) c) d)
finally catch try catch finally
66、在C#中,某程序员定义了一个IDataBase接口及实现该接口的一个类CDataBase,下列
关于该段代码说法正确的是( D )。
using System;
public interface IDataBase {
void OpenTable(string tableName); void UpdateTable(string tableName); }
public class CDataBase:IDataBase {
public void OpenTable(string tableName) {
Console.WriteLine(\打开数据表\); }
public void UpdateTable(string tableName) {
Console.WriteLine(\更新数据表\); }
static void Main() {
CDataBase db = new CDataBase(); db.OpenTable(\); } }
a) 该段代码错误,因为在定义接口时,接口中的方法没有提供实现
b) 该段代码错误,因为接口中声明的方法不是公有的,因此在CDataBase 类中不能访问接口中的方法
c) 该段代码正确,同时由于客户没有调用UpdateTable方法,可以把CDataBase类中UpdateTable方法去掉,代码仍旧正确
d) 该段代码正确,但如果在IDataBase接口中声明一个方法“void Execute(string sql);”,
则必须在CDataBase类中实现该方法
67、在C#中,下列代码的运行结果是( A )。
using System;
public class Student {
public virtual void Exam() {
Console.WriteLine(\学生都要考试\); } }
public class Undergraduate:Student {
public new void Exam() {
base.Exam();
Console.WriteLine(\大学生有选择考试科目的权利\); } }
public class Test {
static void Main() {
Student stu = new Undergraduate(); stu.Exam(); } }
a) 学生都要考试
b) 大学生有选择考试科目的权利 c) 学生都要考试
大学生有选择考试科目的权利 d) 学生都要考试 学生都要考试
68、在C#中,下列代码的运行结果是( A )。
using System; struct Student {
public int age; public string name;
public Student(int age,string name) {
this.age = age; this.name = name; }
}
public class Test {
static void Main() {
Student stu1 = new Student(18,\小芳\); Student stu2 = new Student(24,\小刚\); stu2 = stu1; stu1.age = 30;
stu1.name = \小燕\;
Console.WriteLine(stu2.age); Console.WriteLine(stu2.name); } }
a) b) c) d)
18 小芳 18 小燕 30 小燕 30 小芳
69、在C#中,下列代码的运行结果是( C )。
using System; class Student {
public int age; public string name;
public Student(int age,string name) {
this.age = age; this.name = name; } }
public class Test {
static void Main() {
Student stu1 = new Student(18,\小芳\); Student stu2 = new Student(24,\小刚\); stu2 = stu1; stu1.age = 30;
stu1.name = \小燕\;
Console.WriteLine(stu2.age); Console.WriteLine(stu2.name); } }
a) 18 小芳 b) 18 小燕 c) 30 小燕 d) 30 小芳
70、关于以下C#代码的说法正确的是( B )。
using System;
namespace Microsoft {
class Student {
string type = \高级程序员\; internal string name = \李明\; }
public class Test {
static void Main() {
Student stu = new Student(); //1 Console.WriteLine(stu.type); //2 Console.WriteLine(stu.name); //3 } } }
a) b) c) d)
代码1错误; 代码2错误; 代码3错误; 代码都正确;
71、在ADO.NET中,已知变量sqlCom是一个SqlCommand对象,则下列代码运行时
将出现异常的是( D )。
SqlDataReader reader = sqlCom.ExecuteReader();//1 reader.Read(); //2 reader.Close(); //3 reader.Read(); //4