自考Java语言程序设计一程序设计综合题汇总

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

更多优质自考资料尽在百度贴吧自考乐园俱乐部()欢迎❤加入...欢迎❤交流...止不住的惊喜等着你.........════════════════════════════════════════════════════════════════════自考乐园,自考学习交流、资料共享的好去处!自考乐园,自考人自己的家园....俱乐部id:5346389(请牢记它哦~在百度贴吧的搜索框中输入俱乐部id,可以直接进入俱乐部自考Java语言程序设计一程序设计综合题汇总程序设计综合题(程序填空和编程题)一、程序填空,阅读下列程序并完成程序填空1、用JavaApplet小应用程序完成下列填空3.2importjava.applet.*;importjava.【awt】.*;publicclasstest1_1extends【Applet】{publicvoidpaint(【Graphics】g){intx=2,y=1;【switch】(x+y){case1:g.setColor(Color.red);g.drawString(“我是红色”,5,10);break;case2:g.setColor(Color.blue);g.drawString(“我是蓝色”,5,10);break;case3:g.setColor(Color.green);g.drawString(“我是绿色”,5,10);break;【default】:g.drawString(“没有设置颜色”,5,10);}}}1awt2Applet3Graphics4switch5default2、3.2importjava.【applet】.*;importjava.awt.*;publicclasstest1_1【extends】Applet{publicvoidpaint(Graphicsg)int【sum=0】;for(inti=1;【i=100】;i++)sum=sum+i;g.【drawString】(“sum=”+sum,10,20);}1applet2extends3sum=04i=1005drawString更多优质自考资料尽在百度贴吧自考乐园俱乐部()欢迎❤加入...欢迎❤交流...止不住的惊喜等着你.........════════════════════════════════════════════════════════════════════自考乐园,自考学习交流、资料共享的好去处!自考乐园,自考人自己的家园....俱乐部id:5346389(请牢记它哦~在百度贴吧的搜索框中输入俱乐部id,可以直接进入俱乐部3、3.2【public】classtest1_1{public【static】voidmain(【String】args[]){inti,j;for(j=2;j=50;j++)for(i=2;i=j/2;i++){if(【j%i】)break;}if(ij/2)System.【out】.pritnln(j+”是素数”);}}1public2static3String4j%i==05out4、4.5importjava.【applet】.*;importjava.awt.*;【class】Chengji{floatf(floatx,floaty){returnx*y;}}classXiangjia【extends】Chengji{floatf(floatx,floaty){returnx+y;}}publicclasstest1_1extendsApplet{Xiangjiasum;publicvoid【init()】{sum=newXiangjia();}publicvoidpaint(【Graphics】g){g.drawString(“sum=”+sum.f(4,6),5,20);}}1applet2class3extends4init()5Graphics5、4.5【class】Student{intnumber;Stringname;更多优质自考资料尽在百度贴吧自考乐园俱乐部()欢迎❤加入...欢迎❤交流...止不住的惊喜等着你.........════════════════════════════════════════════════════════════════════自考乐园,自考学习交流、资料共享的好去处!自考乐园,自考人自己的家园....俱乐部id:5346389(请牢记它哦~在百度贴吧的搜索框中输入俱乐部id,可以直接进入俱乐部【Student】(intnumber,Stringname){this.number=number;this.name=name;Systemout.println(“Iam”+name+”Mynumberis”+number);}}classUniver_Student【extends】Student{boolean婚否;Univer_Student(intnumber,Stringname,booleanb){【super】(number,name);婚否=b;System.out.pritnln(“婚否=”+婚否);}}publicclasstest1_1{publicstaticvoidmain(Stringargs[]){Univer_Studentzhang=【new】Univer_Student(9901,”和小林”,false);}}1class2Student3extends4super5new6、5.7importjava.applet.*;importjava.awt;classtest1_extends【Applet】{【String】tom;publicvoid【init()】{tom=”2203026206209021”;}publicvoidpaint(【Graphics】g){if((tom.【startsWith】(“”220))&&(tom.endsWith(“1”)||tom.endsWith(“3”)))g.drawString(“tom是吉林人,男性”,10,10);}}1Applet2String3init()4Graphics5statsWith7、5.11importjava.applet.*;importjava.【awt】.*;publicclasstest1_1extends【Applet】{【String】tom=”Iamagoodcat”;intx,y,z;publicvoidpaint(Graphicsg){更多优质自考资料尽在百度贴吧自考乐园俱乐部()欢迎❤加入...欢迎❤交流...止不住的惊喜等着你.........════════════════════════════════════════════════════════════════════自考乐园,自考学习交流、资料共享的好去处!自考乐园,自考人自己的家园....俱乐部id:5346389(请牢记它哦~在百度贴吧的搜索框中输入俱乐部id,可以直接进入俱乐部x=tom.【indexOf】(“a”);y=tom.indexOf(“good”,2);z=tom.indexOf(“a”,7);g.【setColor】(Color.red);g.drawString(“”+x+”:”+y+”:”+z,20,20);}}1awt2Applet3String4indexOf5setColor8、8.1【import】java.applet.*;importjava.awt.*;publicclasstest1_1extends【Applet】{【TextField】text1,text2;publicvoid【init()】{text1=newTextField(“输入密码:”,10);text1.setEditable(false);text2=newTextField(10);text2.【setEchoChar】(‘*’);add(text1);add(text2);}}1import2Applet3TextField4init()5setEchoChar8、9.1【import】java.applet.*;importjava.awt.*;publicclasstest1_1extends【Applet】{【Button】button1,button2;publicvoid【init()】{button1=newButton();button2=newButton(“确定”);【add】(button1);add(button2);}}1import2Applet3Button4init()5add9、10.1importjava.【applet】.*;importjava.awt.*;publicclassTest1_1【extends】Applet{【Label】labe1;【TextField】text1;publicvoidinit(){更多优质自考资料尽在百度贴吧自考乐园俱乐部()欢迎❤加入...欢迎❤交流...止不住的惊喜等着你.........════════════════════════════════════════════════════════════════════自考乐园,自考学习交流、资料共享的好去处!自考乐园,自考人自己的家园....俱乐部id:5346389(请牢记它哦~在百度贴吧的搜索框中输入俱乐部id,可以直接进入俱乐部label1=newLabel(“输入姓名”);label1.【setBackgound】(Color.red);text1=newTextField(10);add(label1);add(text1);}}1applet2extends3Label4TextField5setBackgroud10、11.1importjava.awt.*;importjava.applet.*;publicclasstest1_1【extends】Applet{【panel】p;【Scrollpane】scrollpane;publicvoid【init()】{p=【new】Panel();scrollpane=newScrollpane(Scrollpane.SCROLLBARS_ALWAYS)}}1extends2Panel3ScroolPane4init()5new11、13.1importjava.applet.*;importjava.awt.*;classMypanel1extends【Panel】{【Checkbox】box1,box2;Mypanel1(){box1=newCheckbox(女生);box2=newCheckbox(男生);add(box1);add(box2);}}publicclassTest1_2extends【Applet】{Mypanel1panel1;publicvoidinit(){panel1=【new】Mypanel1();【add】(panel1);}}1Panel2Checkbox3Applet4new5add12、15.1更多优质自考资料尽在百度贴吧自考乐园俱乐部(http

1 / 12
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功