java工程師基礎筆試題(一)

 

一.選擇和填空  (不定項哦!)

1,以下是一份文件名爲Test2.java的源文件,請問,編譯該文件以後會生成幾份字節碼文件java

class Test{數組

class Inner{}oop

        static class hh{}測試

}spa

class Test1{設計

interface IInterface{}對象

}接口

enum Gender{開發

}get

 

A 1   B 3   C 5  D 6

 

2,下列代碼C.java

public class Hello{

/**

 *  只是一個測試類

 *  /**

 *     您好,java

 *  **/ 

 *  // 請仔細找茬喔,親!

 **/

 static public void main(String[] a){

 System.out.println('您好,java'); 

 }

}

 

請標出上面代碼錯誤的地方________________

 

3,下列哪些是java的關鍵字

A、default 

B、loop

C、do

D、Class

E、null

F、java

G、String

H、false

 

4,下列哪些代碼符合java規範(編譯不會報錯):

Apublic static void main(){} 

Bpublic void method(){

private Integer num; 

   }

Cpublic Method(){

        int num;

System.out.println(num);

   } 

Dprivate $5person=5; 

Epublic int  5i = 100;

 

5,下列哪些變量的聲明是正確的?

    Abyte i=128; 

    Bint i = 0220; 

    Cboolean flag = Boolean.TRUE; 

    Dint number = 'A'; 

    Efloat y = 0x123; 

    Flong a = 0x123l; 

   

6,下列代碼運行結果是:

public static void main(String[] args){       

 boolean flag=false;

 int i=0;

     if(flag||i>100){

  System.out.println("step1");

         }else if(!!flag && i/0>8){

      System.out.println("step2");

         }else{

  System.out.println("step3");

         }

}

A、運行時報錯

B、打印step1

C、打印step2

D、打印step3

E、編譯時報錯

7,下面代碼的運行結果是:

public static void main(String[] args){

int i=1;

int j=++i;

if(j++>3){

++j;

}else{

i++;

int k=++j>4?j++:i++; 

System.out.println(i); 

}

A2

B3

C4

D、運行時報錯

八、下面的程序執行結果是:

public static void main(String[] args) {  

        int i = 0;  

        for (i++; i++ < 10; i++);  

        System.out.println(++i);  

}  

A、輸出0

B、輸出13

C、輸出1

D、輸出12

    

9,下面的程序輸出

public static void main(String[] args){

for(int i=0;i<3;i++){

switch(i){

case 1:

System.out.println("a");

break;

case 0:

System.out.println("b");

break;

default:

System.out.println("c");

case 2:

System.out.println("d");

 

}

}

}

請寫出執行的結果______________

10,下面哪些方法是void show(int a,char b,boolean c){}方法的重載?

A、void show(char b, int a, boolean c){}

B、int show(boolean a,char c ,int b){}

C、void show(int a,char b,double c){}

D、void show(int x,char y,boolean z){}

E、int show(int x,double y){}

F、int show(int x, char y,boolean z){}

 

11,下面哪一個聲明數組的方式是正確的?

A、int i[]=null;  

B、int[] j=new Integer[](); 

C、int[] k=new int[]{1,2,3};

D、int[] L={1,2,3};

E、int[] m={}; 

F、String[] s=new String[]{"1",'2',"3"}; 

G、String[] s=new String[3];

H、class A{}

public class B{

private A[] ={new A(),new A(),new A()};

}

I、class A{}

public class B{

private A[] =new A[]{new A(),new A(),new A()};

}

12下面哪一項說法是正確的?

A.在一個子類中一個方法不是public的就不能被重載 

B.覆蓋一個方法只須要知足相同的方法名和參數類型就能夠了

C.覆蓋一個方法必須須要相同的方法名參數和返回類型

D.一個覆蓋的方法必須有相同的方法名、參數名和參數類型

 

13下面代碼的輸出結果是多少?___________

class A {

    public static void prt() {

        System.out.println("1");

    }

    public A() {

        System.out.println("A");

    }

}

public class B extends A {

    public static void prt() {

        System.out.println("2");

    }

    public B() {

        System.out.println("B");

    }

    public static void main(String[] args) {

        A a = new B();         

          a = new A();     

 }

}

14下面代碼的輸出結果是多少?__________

class Parent {

protected String value = "123";

public String getValue() {

      return value;

}

}

public class Child extends Parent {

protected String value = "456";

public static void main(String[] args){

Child c=new Child(); 

System.out.println(c.getValue()); 

}

}

15,表達式(0 > 0 || 0/0 == 0)結果爲_____________;

二,主觀題

1,請簡要寫出搭建java開發環境的步驟和java跨平臺原理。

2intInteger均可以表明一個整數,這二者在使用上有什麼區別嗎?爲何JDK中要設計兩個數據類型來表示同一種數據?

3,談談你對面向對象特徵的理解並舉例說明。

4,談談你對抽象類和接口的理解。

5,請說說方法覆寫和方法重載的區別

6,面向對象的基本特徵,並簡單述之

7,多態的做用

相關文章
相關標籤/搜索