閱讀屋>筆試> Java筆試題

Java筆試題

Java筆試題推薦

  一、100,100,102,106,112,120 ,130

  0,2,4,6,8

  x-8 = 2

  x = 10

  n-120 = x

  n = 130

  二、有兩個陣列A,B,B陣列中的元素包含在A陣列中,請寫一段程式碼把A陣列中B沒有的元素放到C陣列中。

  int [] A = new int[]{0,1,2,3,4,5,6,7,8,9};

  int [] B = new int[]{2,4,6,8};

  int [] C =new int[A.length-B.length];

  int count = 0;

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

  boolean bool = true;

  for(int j = 0;j < B.length;j++){

  if(A == B[j]){

  bool = false;

  }

  }

  if(bool){

  C[count] = A;

  count++;

  }

  }

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

  System.out.println(C);

  }

  三、假如陣列中都是數字,而且已經按大小排序,請寫一段程式碼最快效率把上一題的元素放到C陣列中。

  int [] num = new int[]{0,1,2,3,4,5,6,7,8,9};

  int [] temp = new int[num.length];

  temp = num;

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

  System.out.println(temp);

  }

  四、寫一個對陣列的排序的程式碼段。

  int [] num = new int[]{4,6,2,7,1,3,9,8,5,0};

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

  for(int j =0;j < num.length;j++){

  if(num < num[j]){

  int temp = 0;

  temp = num;

  num = num[j];

  num[j] = temp;

  }

  }

  }

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

  System.out.println(num);

  }

  五、jsp與servlet的區別?它們的生命週期?jsp或servlet的'轉發(forword),包含(include),重定向(Redirect)的區別?

  六、MVC的概念?你用過哪些基於MVC的框架?

【Java筆試題】相關文章: