您好,欢迎来到品教教育网。
搜索
您的当前位置:首页中兴JAVA面试题目(含答案)

中兴JAVA面试题目(含答案)

来源:品教教育网
JAVA语言试题目

一、单选择题(每小题2分,共10)

1、编译Java Application 源程序文件将产生相应的字节码文件,这些字节码文件的扩展名为( )

A. .java B. .class

C..html D. .exe

2 main方法是Java Application程序执行的入口点,关于main方法的方法头以下哪项是合法的( )?

Apublic static void main

Bpublic static void main String args[]

Cpublic static int mainString [] arg

Dpublic void mainString arg[]

3、设 x = 1 , y = 2 , z = 3,则表达式 y+z--/++x 的值是( )

A. 3 B. 3. 5

C. 4 D. 5

4、在Java Applet程序用户自定义的Applet子类中,一般需要重载父类的( )方法来完成一些画图操作。

A. start( ) B. stop( )

C. init( ) D. paint( )

5、不允许作为类及类成员的访问控制符的是( )

A. public B. private

C. static D. protected

二、填空题(每空格1分,共20分)

1、开发与运行Java程序需要经过的三个主要步骤为

2、如果一个Java Applet源程序文件只定义有一个类,该类的类名为MyApplet,则类MyApplet必须是 的子类并且存储该源程序文件的文件名为

3、如果一个Java Applet程序文件中定义有3个类,则使用Sun公司的JDK编译器 编译该源程序文件将产生 个文件名与类名相同而扩展名为 的字节码文件。

4、在Java的基本数据类型中,char型采用Unicode编码方案,每个Unicode码占用 字节内存空间,这样,无论是中文字符还是英文字符,都是占用 字节内存空间。

BufferedReader br=new BufferedReader(

new InputStreamReader(System.in));

a[i] = Integer.parseInt(br.readLine( ));

} catch ( IOException e ) { } ;

for ( i = n - 1 ; i >= 0 ; i -- )

System.out.print(a[i]+" ");

System.out.println( );

}

}

3.

public abstract class ABC{

long aver=0;

long max=0;

long min=0;

int testSum=0;

protected abstract actionPerformed();

public void ABC (int testSum) {

long start;

long interval;

long sum=0;

this.testSum = testSum;

for (int i=0;i

start=(new java.util.Date()).getTime();

actionPerformed();

interval=(new java.util.Date()).getTime()-start;

sum+=interval;

if (interval>max) max=interval;

if (i==0) min=interval;

else if (interval

}

aver=sum/testSum;

System.out.println("aver:\"+aver+" miliSeconds");

System.out.println("max:\"+max+" miliSeconds");

System.out.println("min:\"+min+" miliSeconds");

}

}

四、写出下面程序的运行结果(每小题14分,共28)

1

import java.io.*;5、设 x = 2 ,则表达式 ( x + + )3 的值是

6、若x = 5y = 10,则x < yx >= y的逻辑值分别为

7 方法是一种仅有方法头,没有具体方法体和操作实现的方法,该方法必须在抽象类之中定义。 方法是不能被当前类的子类重新定义的方法。

8、创建一个名为MyPackage 的包的语句是 ,该语句应该放在程序的位置为:

9、设有数组定义:int MyIntArray[ ] = { 10 , 20 , 30 , 40 , 50 , 60 , 70}; 则执行以下几个语句后的输出结果是

int s = 0 ;

for ( int i = 0 ; i < MyIntArray.length ; i + + )

if ( i % 2 = = 1 ) s += MyIntArray[i] ;

System.out.println( s );

10、在Java程序中,通过类的定义只能实现 重继承,但通过接口的定义可以实现 重继承关系。

三、写出下列程序完成的功能。(每小题14分,共42)

1

public class Sum{

public static void main( String args[ ]) {

double sum = 0.0 ;

for ( int i = 1 ; i <= 100 ; i + + )

sum += 1.0/(double) i ;

System.out.println( "sum="+sum );

}

}

2

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 < n ; i ++ )

try {

public class abc{

public static void main(String args[ ]) {

String str1=" Hello!" ;

String str2=" I love JAVA." ;

System.out.println(new AB(str1,str2));

System.out.println(str2);

}

}

class AB {

String s1;

String s2;

AB( String str1 , String str2 ){

s1 = str1;

s2 = str2;

str2+=str1;

}

public String toString( ) {

return s1+s2;

}

}

2

class Ex{

public static void main(String[] args) {

Fx f=new Fx(5);

}

Ex() {

System.out.println("Ex,no-args");

}

Ex(int i) {

System.out.println("Ex,int");

}

}

class Fx extends Ex{

Fx() {

super();

System.out.println("Fx,no-args");

}

Fx(int i) {

this();

System.out.println("Fx,int");

}

}

答案:

BBBDC

编辑源程序编译生成字节码解释运行javaclassjar

AppletMyApplet.java

Javac.exe3.class

22

2/3

Truefalse

抽象,抽象

package MyPackage; 程序第一句

120

单、多

1/11/100相加,输出结果

对输入的10个数字逆序输出

测试actionPerformed()这个方法的平均运行时间,最大运行时间和最小运行时间

Hello! I love JAVA. Hello!

I love JAVA.

Ex,no-args

Fx,no-args

Fx,int

友情提示:部分文档来自网络整理,供您参考!文档可复制、编制,期待您的好评与关注!

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- pinjiaoyu.com 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务