没有合适的资源?快使用搜索试试~ 我知道了~
首页C#高级编程练习题目(内附答案)
资源详情
资源评论
资源推荐
C#高级编程
1、public class TEApp
{
public stac void ThrowExcepon()
{
throw new Excepon();
}
public stac void Main()
{
try{
Console.WriteLine("try");
ThrowExcepon();
}
catch(Excepon e){
Console.WriteLine("catch");
}
&nally{
Console.WriteLine("&nally");
}
}
}上述 C#代码运行结果是( ) (选择一项)
A)try
&nally
B)try
catch
&nally √
C)catch
&nally
D)try
2、public class Father{
public string surname;
public Father(string name){
this.surname = name;
Console.WriteLine(name);
}
}
public class Son : Father{
private int age;
public Son(int age) : base("关羽"){
this.age = age;
Console.WriteLine(age);
}
stac void Main(){
Son son = new Son(18);
C#高级编程
}
}在 C#中,上述代码的运行结果是( ) (选择一项)
A)关羽
18 √
B)18
关羽
C)18
D)关羽
3、public interface IAccount{
public void PostInterest();
public void DeductFees(int feeSchedule);
}
class BusinessAccount : IAccount{
int A;
public stac void Main(){
BusinessAccount B = new BusinessAccount();
Console.WriteLine(B.A);
Console.ReadLine();
}
public void PostInterest(){
A = A + 1;
}
public void DeductFees(int feeSchedule){
A = A + feeSchedule;
}
}以下的描述正确的是( ) (选择一项)
A)程序将正常运行,输出为 0
B)程序将出现编译错误,指示 public 关键字对接口无效 √
C)程序编译正常,但是出现运行时错误,提示变量 A 没有初始化
D)程序将出现编译错误,指示不能在实现接口的类 BusinessAccount 中定义成员 A
4、public class Teacher{
public Teacher (string name){
Console.WriteLine("老师的名字叫"+ name);
}
}
public class Test:Teacher{
public Test(string name){
Console.WriteLine("学生的名字叫"+ name);
}
}分析如上的 C#代码段,运行后将输出( ) (选择一项)
A)编译报错 √
B)老师的名字叫李明
C#高级编程
C)老师的名字叫李明
学生的名字叫李明
D)学生的名字叫李明
5、在 C#程序中,一个类( ) (选择一项)
A)在一个程序中只能有一个子类
B)可以继承多个类
C)只能实现一个接口
D)可以实现多个接口 √
6、public class Student
{
public virtual void Exam()
{
Console.WriteLine("学生都要考试");
}
}
public class Undergraduate : Student
{
public new void Exam()
{
base.Exam();
Console.WriteLine("大学生有选择考试科目的权利");
}
}
public class Test
{
stac void Main()
{
Student stu = new Undergraduate();
stu.Exam();
}
}
在 C#中,上述代码的运行结果是( ) (选择一项)
A)学生都要考试
大学生有选择考试科目的权利
B)学生都要考试 √
C)大学生都要考试
D)大学生有选择考试科目的权利
学生都要考试
7、在 C#程序中,如果类 B 要继承类 A,类 B 正确的定义为( ) (选择一项)
A)public class B :: A
B)public class B from A
C#高级编程
C)public class B inherit A
D)public class B : A √
8、下列关于 C#的异常处理的描述,错误的是()。(选择二项)
A)使用 throw 语句既可以引发系统异常,也可以引发由开发人员创建的自定义异常
B)try 块必须跟 catch 块组合使用,不能单独使用 √
C)一个 try 块可以跟随多个 catch 块
D)在 try…catch…&nally 块中,即便开发人员编写强制逻辑代码,也不能跳出 &nally 块的执
行 √
9、public abstract class Animal{ 代码 1
public abstract void Eat(); 代码 2
public void Sleep(){} 代码 3
}以下关于 C#代码地描述正确的是()
A)代码 2 错误
B)代码 3 错误
C)代码 1 错误
D)代码无错误 √
10、public abstract class Animal{
public abstract void Eat();
public void Sleep(){}
}以下关于 C#代码地描述正确的是( ) (选择一项)
A)代码错误,因为类中方法没有实现
B)通过代码 Animal an = new Animal;可以创建一个 Animal 对象
C)该段代码正确 √
D)代码错误,因为类中存在非抽象方法
11、class A{
public string F(){return "A";}
}
class B:A{
new public string F(){return "B";}
stac void Main( ){
A objA = new B( );
Console.WriteLine(objA.F( ));
}
}以下描述正确的是( ) (选择一项)
A)以上代码存在错误,子类 B 中不能再定义方法 F
B)以上代码存在错误,子类 B 中的方法 F 应该添加 new 关键字进行方法重写
C)以上代码无错误,并在控制台打印输出 B
D)以上代码无错误,并在控制台打印输出 A √
12、在 C#中,下列代码的运行结果是()。(选择一项)
C#高级编程
int[] num = new int[]{1,3,5};
List<int> arr = new List<int>();
for(int i=0;i<num.Length;i++)
arr.Add(num[i]);
Console.Write(arr[2]);
A)1
B)4
C)3
D)5 √
13、以下的 C#代码是子类中方法重写的例子:
class intaddion {
public void add(){
int &rstnum = 1;
int secondnum = 2;
console.writeline("两数之和这:{0}",&rstnum + secondnum);
}
}
class stringaddion : intaddion{
//(1)此处添加正确的代码行{
string &rststr = "a";
string secondstr = "b";
console.writeline("两字符串之和为:{0}",&rststr + secondstr);
}
}则(1)处需要填写的正确的代码行为() (选择一项)
A)new void public add ()
B)public override void add ()
C)public new void add()√
D)add ()
14、public struct Inventory{
public string Item;
public int unitPrice;
public int Quanty;
}
public Inventory CreateItem(){
Inventory temp;
Console.Write("Enter the Items name : ");
temp.Item = Console.ReadLine();
Console.Write("Enter the Unit Price : ");
temp.unitPrice = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter the item Quanty : ");
temp.Quanty = Convert.ToInt32(Console.ReadLine());
return temp;
剩余27页未读,继续阅读
LOJGG
- 粉丝: 38
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- stc12c5a60s2 例程
- Android通过全局变量传递数据
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论1