java复习资料

2026/1/26 20:27:00

public class Test {

public static void main(String[] args) {

CollegeStudent cs=new CollegeStudent(); } }

10.通过键盘输入10个整数,并按输入的倒序输出这10个整数。

import java.io.*; public class Reverse {

public static void main(String args[]) {

int i,n=10;

int a[]=new int[10];

for (i=0;i

{ BufferedReader br=new BufferedReader( );

a[i]=Integer.parseInt( ); //输入一个整数 }

catch(IOException e){}; for(i=n-1;i>=0;i--)

System.out.print(a[i]+\

System.out.println(); } }

11.以下程序的输出结果为 。

public class EqualOrNot {

public static void main(String args[]) {

B b1=new B(5); B b2=new B(5);

System.out.println(b1==b2);

System.out.println(b1.equals(b2));

} }

class B {

int x;

B(int y) {

x=y; } }

12.以下程序的输出结果为 。 class Parent {

void printMe() {

System.out.println(\ }

}

class Child extends Parent {

void printMe() {

System.out.println(\ }

void printAll() {

super.printMe(); this.printMe(); printMe(); } b }

public class Test_this {

public static void main(String args[]) {

Child myC=new Child(); myC.printAll(); } }

13.以下程序的输出结果为 。 class Cruncher {

void crunch( int i ) {

System.out.print(“int”); }

void crunch(String s) {

System.out.print(“String”); }

public static void main(String args[ ])

{

Cruncher crun=new Cruncher ( ); char ch=’h’; int i=12;

crun.crunch(ch);

System.out.print(“,”); crun.crunch(i); } }

14.阅读以下程序: import java.io.*;

public class AboutFile {

public static void main(String[ ] args)

{

BufferedReader b=new BufferedReader (new InputStreamReader(System.in)); String s;

System.out.flush(); try

{ s=b.readLine();

System.out.println(“String is:”+s); }

Catch(IOException e)

{ System.out.println(e.getMessage()); } } }

运行以上程序,若从键盘输入: java<回车>

则输出结果为 。 15.写出以下程序的运行结果。 public class TryCatchFinally {

static void Proc( int sel )

{ try {

if( sel==0 )

{

System.out.println(\

return;

}

else if( sel==1 ){ int i=0; int j=4/i;} }

catch( ArithmeticException e )

{ System.out.println(\

catch( Exception e )

{ System.out.println(\

finally

{ System.out.println(\

}

public static void main( String args[] ) { Proc( 0 ); Proc( 1 ); } }

输出结果为: 。 15.阅读以下程序,写出输出结果。 class Animal {

Animal() { System.out.print (\}

public class Dog extends Animal {

Dog()

{ System.out.print (\public static void main(String[] args) { Dog snoppy= new Dog(); } }

输出结果为: 。

编程题

1、编写一个类,要求该类实现一个接口,该接口有3个abstract方法: public abstract void f(int x);

public abstract void g(int x, int y);

public abstract double h(double x); 要求在应用程序的主类中使用该类创建对象,并使用接口回调来调用方法:f(),g()和h()。 2、创建一个窗体,窗体中有一个按钮btn,二个文本框txt1和txt2。当单击按钮后,第一个文本框的内容会显示在第二个文本框当中。

3.编写一个应用程序,设计4个按钮,分别命名为“加”、“减”、“乘”、“除”,有3个文本框。单击相应的按钮,将两个文本框的数字做运算,在第三个文本框中显示结果。 4.编写程序,完成文件复制功能,即将a.txt文件内容复制到b.txt文件中去。


java复习资料.doc 将本文的Word文档下载到电脑
搜索更多关于: java复习资料 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

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