C#综合练习附答案.pdf

上传人:s****u 文档编号:12791501 上传时间:2020-05-24 格式:PDF 页数:9 大小:147.04KB
返回 下载 相关 举报
C#综合练习附答案.pdf_第1页
第1页 / 共9页
C#综合练习附答案.pdf_第2页
第2页 / 共9页
C#综合练习附答案.pdf_第3页
第3页 / 共9页
点击查看更多>>
资源描述
一、选择题1.下列程序所计算的数学式是( )int a=0,i=2;while(i=0;j-)Console.Write(“00”,numsj);Console.WriteLine();答案:108361224241236810 2、classFruit publicstringcolor;publicstringshape;publicFruit(stringc,strings) color=c;shape=s;classTest publicstaticvoidMain() FruitOrange=newFruit(orange,round);Console.WriteLine(0,1,Orange.color,Orange.shape);答案:orange,round 3、usingSystem;classPoint publicintx,y;publicPoint(intx,inty) this.x=x;this.y=y;classTest staticvoidMain() Point p=newPoint(5,6);Console.WriteLine(x=0,p.x);Console.WriteLine(y=0,p.y); 答案:x=5y=64、classDecon1publicDecon1() Console.WriteLine(“调用构造函数Decon1”); Decon1() Console.WriteLine(“调用析构函数Decon1”);classDecon2publicDecon2() Console.WriteLine(“调用构造函数Decon2”);Decon2() Console.WriteLine(“调用析构函数Decon2”); classTest publicstaticvoidMain() Decon1 dec1=newDecon1();Decon2 dec2=newDecon2();答案:调用构造函数Decon1调用构造函数Decon25、using System;classTestpublicvoidmyMeth() intj;for(j=1;j=5) j=j*2;Console.WriteLine(j);return; elsej=j*3;Console.WriteLine(j);return; staticvoidMain()Testlei=newTest();lei.myMeth();答案:167、usingSystem;classTest publicvoidSwap(intx,inty) intk;k=x;x=y;y=k;staticvoidMain() inta=8,b=68;Console.WriteLine(a=0,y=1,a,b);Test sw=newTest();sw.Swap(a,b);Console.WriteLine(a=0,y=1,a,b); 答案:a=8,b=68a=8,b=688、usingSystem;classTestoverLoad publicvoidprint(inti) Console.WriteLine(输出的整数=0,i);publicvoidprint(string s) Console.WriteLine(输出的字符串=0, s); publicvoidprint(doubled) Console.WriteLine(输出的双精度数=0,d); class testpublicstaticvoidMain() TestoverLoad app=newTestoverLoad();app.print(6);app.print(理解方法重载了吗?);app.print(3.14);答案:输出的整数=6输出的字符串=理解方法重载了吗? 输出的双精度数=3.149、classA publicintcount;publicA() count=-1;publicA(intn) count=n; classTest staticvoidMain() Aa=newA();Console.WriteLine(count=0,a.count);Ab=newA(5);Console.WriteLine(count=0,b.count);答案:count=-1count=510、有以下程序,计算结果 staticvoidMain(stringargs) Console.Write(输入一整数);Strings=Console.ReadLine();intnum=int.Parse(s);if(num+5) Console.WriteLine(num);else Console.WriteLine(-num);Console.Read();运行时,从键盘输入5,则输出结果是:5
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 图纸专区 > 考试试卷


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!