首页 > 编程知识 正文

java考试摸底测试题,java测试面试题及答案

时间:2023-12-27 22:27:02 阅读:325335 作者:QJCN

本文目录一览:

java基础测试题

答案为 C。

public Test(){

x=35;

}

public Test(String s){}

为构造方法,构造方法规定是不需要用void之类的修饰,也没有返回值

public void Test(double f){

this.x=(int)f;

},这个则是与类名同名的方法,但这样的做法不赞同。

java 测试题,紧急!

public class student

{

int snum;//xuehao

String name;

int escore;//englishscore;

int mscore;

int cscore;//computerscore;

public void setsnum(int snum){this.snum=snum;}

public void setname(String name){this.name=name;}

public void setescore(int escore){this.escore=escore;}

public void setmscore(int mscore){this.escore=escore;}

public void setcscore(int cscore){this.escore=escore;}

public int getsnum(){return snum;}

public String getname(){return name;}

public int getscore(){return escore;}

public int getmcore(){return mscore;}

public int getccore(){return cscore;}

public student(int snum,String name,int escore,int mscore,int cscore)

{

this.setsnum(snum);

this.setname(name);

this.setescore(escore);

this.setmscore(escore);

this.setcscore(escore);

}

public String toString()

{return "snum="+snum+"t name="+name+"t escore"+escore+"t mscore"+mcore+"t cscore"+cscore;}

public int sum(student e)

{return e.getescore()+e.getmscore()+e.getcscore();}

public String compare(Student e1 ,student e2)

{if(e1.sum()==e2.sum())return "等于";

else retuen (e1.sum()e2.sum())?"大于":"小于";}

public float testscore(student e)

{return (e.getescore()+e.getmscore()+e.getcscore())/3;}

public static voia main(String args[])

{

student stu=new student(1,"1",2,3,4);

studentxw sxw=new studentxw(1,"1",2,3,4,"work");

studentxw sbz=new studentbz(1,"1",2,3,4,"work1");

}

}

class studentxw extends student

{

private String work;

public void setwork(String work){this.work=work;}

public String getwork(){return work;}

public studentxw(int snum,String name,int escore,int mscore,int cscore,String work)

{

super(snum,name,escore,mscore,cscore);

this.setwork(work);

}

public float testscore(student e)

{return super.test(e)+3;}

}

class studentbz extends student

{

private String work;

public void setwork(String work){this.work=work;}

public String getwork(){return work;}

public studentxw(int snum,String name,int escore,int mscore,int cscore,String work)

{

super(snum,name,escore,mscore,cscore);

this.setwork(work);

}

public float testscore(student e)

{return super.test(e)+5;}

}

JAVA基础测试题

1 跟java运行的机制有关,java先加载静态域,static int x=10; ,然后静态块static { x+=5;},static { x/=3;}(虽然位置在后但先运行) ,然后静态方法static void main

所以x=10,x=15,x=5.

2 A因为int [ ] x = new int[25],数组建立后,每个元素默认值为0;x[24]=0;x[25] 下标越界,x[0]=0;

3 switch(i)不接受long型,int或者枚举型可以。i=Integer.parseInt(args[0]);虽然这样每课时i还是long型的。

4 c,没什么好说的,就是这么规定的!

java测试题 在线等

1.错误

2.正确

3.正确

4.正确

5.1

6.2

7.2

8.4

9.2

10.2

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。