收藏 分享(赏)

Java语言程序设计模拟题1new.doc

上传人:dzzj200808 文档编号:2279827 上传时间:2018-09-09 格式:DOC 页数:15 大小:56.50KB
下载 相关 举报
Java语言程序设计模拟题1new.doc_第1页
第1页 / 共15页
Java语言程序设计模拟题1new.doc_第2页
第2页 / 共15页
Java语言程序设计模拟题1new.doc_第3页
第3页 / 共15页
Java语言程序设计模拟题1new.doc_第4页
第4页 / 共15页
Java语言程序设计模拟题1new.doc_第5页
第5页 / 共15页
点击查看更多>>
资源描述

1、Java 语言程序设计模拟题(1)一、选择题(每题只有一个正确答案,每题 2 分,共 30 分)1编译 Java Applet 源程序文件产生的字节码文件的扩展名为()A、java B、class C、html D、exe2main 方法是 JavaApplication 程序执行的入口点,关于 main 方法的方法头以下哪项是合法的()?A、public static void main( )B、public static void main( String args )C、public static int main(String arg )D、public void main(Strin

2、g arg )3为 AB 类的一个无参数无返回值的方法 method 书写方法头,使得使用类名 AB 作为前缀就可以调用它,该方法头的形式为()A、static void method( ) B、public void method( )C、final void method( ) D、abstract void method( )4下列哪个是合法的 Java 标识符?()A、Tree B、import java.applet.Applet ;C、import java.io.* ; D、import java.awt.Graphics ;8对于构造函数,下列叙述不正确的是()A、构造函数是类

3、的一种特殊函数,它的方法名必须与类名相同。B、构造函数的返回类型只能是 void 型。C、构造函数的主要作用是完成对类的对象的初始化工作。D、一般在创建新对象时,系统会自动调用构造函数。9设有下面两个类的定义:class Person class Student extends Person long id;/ 身份证号int score;/ 入学总分String name;/ 姓名问:类 Person 和类 Student 的关系是()A、包含关系 B、继承关系C、关联关系 D、无关系,上述类定义有语法错误10 设有下面的两个类定义:class AA void Show() System.o

4、ut.println(“我喜欢 Java!“); class BB extends AA void Show() System.out.println(“我喜欢 C+!“);则顺序执行如下语句后输出结果为:()AA a; BB b;a.Show();b.Show();A、我喜欢 Java! B、我喜欢 C+!我喜欢 C+!我喜欢 Java!C、我喜欢 Java!D、我喜欢 C+!我喜欢 Java!我喜欢 C+!11在 Java 中,一个类可同时定义许多同名的方法,这些方法的形式参数的个数、类型或顺序各不相同,传回的值也可以不相同。这种面向对象程序特性称为()A、隐藏 B、覆盖 C、重载 D、J

5、ava 不支持此特性12在 Java Applet 程序用户自定义的 Applet 子类中,常常重载()方法在 Applet 的界面中显示文字、图形和其它界面元素A、start( ) B、stop( ) C、init( ) D、paint( )13在 Java 中,存放字符串常量的对象属于()类对象A、Character B、String C、StringBuffer D、Vector14在 Java 图形用户界面编程中,若显示一些不需要修改的文本信息,一般是使用()类的对象来实现A、Label B、Button C、TextArea D、TextField15在编写 Java Applet

6、程序时,若需要对发生的事件作出响应和处理,一般需要在程序的开头写上()语句A、import java.awt.* ; B、import java.applet.* ;C、import java.io.* ; D、import java.awt.event.* ;二、写出程序结果(每题 4 分,共 20 分)1、public class AppTestpublic static void main(String args)int i=10,j=5;System.out.println(i+“t”+j);boolean test=false;i=test?i:j;System.out.printl

7、n(i+“t”+j);输出结果:2、public class WhileTestpublic static void main(String args)int i=10;while(i0)System.out.println(i);i-;输出结果:3、public class Lxpublic static void main(String args)trySystem.out.println(“执行 try”);catch(Exception e)System.out.println(“执行 catch”);finallySystem.out.println(“执行 finally”);输出

8、结果:4、class MainTestpublic static void main(String args)if(args.length=0)System.out.println(“没有参数”);elseSystem.out.println(“参数的个数:”+args.length);for(int i=0;i=0)if(a240output(fee);if(a0) System.out.println(“请输入正的用电度数“);static void output(double result)System.out.println(“电费是:“+result);评分标准:完全正确得满分,循环

9、语句表达正确得十分,输入输出语句表达正确得三分,无基本语法错误得两分2、import java.awt.*;import java.awt.event.*;class ChoiceExample extends WindowAdapter implements ItemListenerFrame f;Choice c;Label l;TextField tf;public static void main(String args)ChoiceExample ce=new ChoiceExample();ce.go();void go()f=new Frame(“选择框“);f.setLayou

10、t(new FlowLayout();l=new Label(“your choice“);f.add(l);c=new Choice();c.addItem(“first“);c.addItem(“second“);c.addItem(“third“);f.add(c);tf=new TextField(20);f.add(tf);c.addItemListener(this);f.addWindowListener(this);f.setSize(300,150);f.setVisible(true);publicvoid windowClosing(WindowEvent e)System.exit(0);public void itemStateChanged(ItemEvent e)String s=“your choice is:“;s=s+c.getSelectedItem();tf.setText(s);评分标准:完全正确得满分,实现程序界面得九分,每个事件处理各占三分

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 高等教育 > 大学课件

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报