java试题库程序分析题挑选好最终.doc

上传人:s****u 文档编号:12766826 上传时间:2020-05-23 格式:DOC 页数:8 大小:63KB
返回 下载 相关 举报
java试题库程序分析题挑选好最终.doc_第1页
第1页 / 共8页
java试题库程序分析题挑选好最终.doc_第2页
第2页 / 共8页
java试题库程序分析题挑选好最终.doc_第3页
第3页 / 共8页
点击查看更多>>
资源描述
难度级别:3知识点:继承(5-4)试题内容:class Art Art() System.out.println(Art constructor); class Drawing extends Art Drawing() super(); System.out.println(Drawing constructor); public class Cartoon extends Drawing Cartoon() super(); System.out.println(Cartoon constructor); public static void main(String args) Cartoon x = new Cartoon(); 难度级别:3 知识点:继承(5-4)试题内容:class Game Game(int i) System.out.println(Game constructor); class BoardGame extends Game BoardGame(int i) super(i); System.out.println(BoardGame constructor); public class Chess extends BoardGame Chess() super(11); System.out.println(Chess constructor); public static void main(String args) Chess x = new Chess(); 难度级别:3 知识点:继承(5-4)试题内容:class Vehicle public void drive() System.out.println(Vehicle: drive);class Car extends Vehicle public void drive() System.out.println(Car: drive);public class Test public static void main (String args ) Vehicle v= new Vehicle();Car c= new Car();v.drive();c.drive();v = c;v.drive();难度级别:3 知识点:构造函数的重载(5-3)试题内容:写出下面程序的输出结果class C0 public C0(int x) System.out.println(C0+x); C0() System.out.println(C0); class C1 extends C0 public C1(int x) System.out.println(C1+x); public static void main (String args) new C1(1); 难度级别:3知识点:构造函数的重载(5-3)3、试题内容:写出下面程序的输出结果class Parent Parent() System.out.println(调用父类的parent()构造方法);class SubParent extends Parent SubParent() System.out.println(调用子类的SubParent()构造方法);public class Subroutine extends SubParent Subroutine() System.out.println(调用子类的Subroutine()构造方法);public static void main(String args) Subroutine s = new Subroutine();难度级别:3 知识点:构造函数的重载(5-3)试题内容:class Test public static int MAX=100; Test() System.out.println(调用无参构造方法); Test(int i) System.out.println(调用有参构造方法); public int f(int a) return a+Test.MAX; public int f(int a,int b) return a+b; public class TestDemo public static void main(String args) System.out.println(Test.MAX); Test t1=new Test(); System.out.println(t1.f(10,20); Test t2=new Test(10); System.out.println(t2.f(10); 难度级别:3 知识点:构造函数(4-1)试题内容:查看下列程序并指出其输出结果。class Apublic A()System.out.println(A is called);class B extends Apublic B()super();System.out.println(B is called);public B(String x)super();System.out.println(B is called and input is +x);class C extends Bpublic C()System.out.println(C is called);public C(String x)super(x);System.out.println(c is called and input String is +x);public static void main(String args)new C(how are you);难度级别:3知识点:构造函数(4-1)试题内容:以下程序的输出结果是 。public class Test extends TT public static void main ( String args ) Test t = new Test (Tom); public Test(String s ) super(s); System.out.println(How do you do?); public Test() this (I am Jack); class TT public TT() System.out.println(What a pleasure!); public TT(String s) this(); System.out.println(I am +s); 难度级别:3 知识点:重载试题内容:public class Exam3_3public static void main(String args) System.out.println( test(15,26,4) ); static int test(int x, int y, int z) return test( x, test(y,z);static int test(int x,int y) if(xy) return x; else return y;难度级别:3 知识点:重载(5-3)试题内容:以下程序段的输出结果为 。class IntORString void iosM( int i ) System.out.print(“Integer ”); void iosM(String s) System.out.print(“String ”); public static void main(String args ) IntORStringios=new IntORString ( );ios.iosM(a);ios.iosM(“1”);难度级别:3知识点:重载(5-3)3、试题内容:以下程序段的输出结果为 public class OverLoadTest public static int add(int a, int b) return a + b;public static double add(double a, double b) return a + b;public static int add(int a) return a;public static int add(int a, double b) return 1;public static int add(double a, int b) return 1;public static void main(String args) System.out.println(调用add(int,int)方法: + add(1, 2);System.out.println(调用add(double,double)方法: + add(2.1, 3.3);System.out.println(调用add(int)方法: + add(1);难度级别:3知识点:重载(5-3)试题内容:以下程序段的输出结果为 public class Yikespublic static void go(long n)System.out.println(long);public static void go(short n)System.out.println(short);public static void go(int n)System.out.println(int);public static void main(String args)short y=6;long z=7;go(y);go(z);难度级别:3知识点:对象的比较试题内容:以下程序的输出结果是 。class Compare public static void main(String args) String str1 = new String(abc);String str2 = new String(abc);String str3 = str1;if(str1=str2)System.out.println(str1=str2);elseSystem.out.println(str1!=str2);if(str1=str3)System.out.println(str1=str3);elseSystem.out.println(str1!=str3); 难度级别:3知识点:异常3、以下程序段的输出结果为 public class DemoFinallypublic static void main(String args) String members=new String4;for(int count=0;count3;count+)tryint x;if (count=0) x=1/0;if (count=1) members4=jishou;if (count=2) return; catch(ArrayIndexOutOfBoundsException e)System.out.println(下标越界);catch(ArithmeticException ex)System.out.println(被零除); continue;finally System.out.println(这条语句总会被执行);二、按要求编写程序:1.(1)编写一个父类Test,其中有两个构造方法(一个有参数,一个没有参数)和一个方法fun()。(2)编写一个子类Test2继承Test类,也有两个构造方法(一个有参数,一个没有参数),其中无参的构造方法调用父类对应的构造方法;重写方法fun(),在该方法中要求用super来调用父类的同名方法。(3)编写一个测试类TestDemo,在main方法中分别用父类和子类创建对象,并调用各自的方法fun()。2.编写一个矩形类Rect,包含: 两个protected属性:矩形的宽width;矩形的高height。两个构造器方法:(1)一个带有两个参数的构造器方法,用于将width和height属性初化; (2)一个不带参数的构造器,将矩形初始化为宽和高都为10。 两个方法:(1) 求矩形面积的方法area()(2) 求矩形周长的方法perimeter()
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


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


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

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


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