java语言和www技术机考题资料(8)

2019-05-24 19:45

Student (String name, char sex, int chinese, int english) { this.name=name; this.sex=sex; this.chinese=chinese; this.english=english; } void print() { System.out.println(this.toString()); } public String toString() { return new String(name+\ } } 运行结果: public class Father{ int a=100; public void miner(){ a--; } public static void main(String[] args){ Father x = new Father(); Son y = new Son(); System.out.println(y.a); System.out.println( y.getA()); y.miner(); System.out.println(y.a); System.out.println(y.getA()); } {=0 100 0 99 } } class Son extends Father{ int a = 0; public void plus(){ a++; } public int getA() { return super.a; } } 运行结果: public class Test{ public static void main(String [] args){ int j = 10; System.out.println(j); calculate(j); System.out.println(j);} static void calculate (int j){ for (int i = 0; i < 10; i++) j++; System.out.println(j);} } 运行结果: class A { double f(double x, double y) { return x * y;} } {=10 20 10 } {=The output is 10.0} class B extends A { double f(double x, double y) { return x + y;} } public class Test { public static void main(String args[]) { B obj = new B(); System.out.println(\ } } 运行结果: abstract class Shape { abstract void display(); } class Circle extends Shape { void display() { System.out.println(\} class Rectangle extends Shape { void display() { System.out.println(\} class Triangle extends Shape { void display() { System.out.println(\} {=Circle Rectangle Triangle } public class Test{ public static void main(String args[]){ (new Circle()).display(); (new Rectangle()).display(); (new Triangle()).display(); } } 运行结果: public class Class1 { public static void main(String args[ ]){ int i , Max , Min ; int a[ ] = { -12,67,8,98,23,56,254,55,99,100 }; Max = Min = a[0]; for ( i = 1 ; i < a.length; i ++ ) { if ( a[i]Max ) Max = a[i]; } System.out.println( “Max=”+Min+\“Min=”+Min ); System.out.println( ); } } 运行结果: public class FooBar{ public static void main(String[] args){ int i,j; {=Max=254 Min=-12} {=i=5,j=4} for(i=0;i<=5;i++){ for(j=5;j>=0;--j) if(i>j) break; } System.out.println(\ } } 运行结果: 程序阅读题:若文件test.dat不存在,则试图编译并运行以下程序时会发生什么情况? import java.io.*; class TestIO { public static void main(String[] args) { try{ RandomAccessFile raf=new RandomAccessFile(\ int i=raf.readInt(); } catch(IOException e){System.out.println(\ } } 程序阅读题:以下程序的输出结果为 。 public class EqualsMethod { public static void main(String[] args) { Integer n1 = new Integer(12); Integer n2 = new Integer(12); System.out.print(n1= =n2); System.out.print(“,”); {=程序发生异常,捕获异常后并输出: IO Exception } {=false,true}


java语言和www技术机考题资料(8).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:时事热点2010

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: