本文目錄一覽:
- 1、java基礎測試題
- 2、java 測試題,緊急!
- 3、JAVA基礎測試題
- 4、java測試題 在線等
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
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/233938.html