第一篇:JAVA工程師筆試題
【程序17】
題目:猴子吃桃問題:猴子第一天摘下若干個桃子,當即吃了一半,還不癮,又多吃了一個 第二天早上又將剩下的桃子吃掉一半,又多吃了一個。以后每天早上都吃了前一天剩下 的一半零一個。到第10天早上想再吃時,見只剩下一個桃子了。求第一天共摘了多少。public class lianxi17 { public static void main(String[] args){ int x = 1;for(int i=2;i<=10;i++){ x =(x+1)*2;} System.out.println(“猴子第一天摘了 ” + x + “ 個桃子”);} } 【程序18】
題目:兩個乒乓球隊進行比賽,各出三人。甲隊為a,b,c三人,乙隊為x,y,z三人。已抽簽決定比賽名單。有人向隊員打聽比賽的名單。a說他不和x比,c說他不和x,z比,請編程序找出三隊賽手的名單。public class lianxi18 { static char[] m = { 'a', 'b', 'c' };static char[] n = { 'x', 'y', 'z' };public static void main(String[] args){ for(int i = 0;i < m.length;i++){ for(int j = 0;j < n.length;j++){ if(m[i] == 'a' && n[j] == 'x'){ continue;} else if(m[i] == 'a' && n[j] == 'y'){ continue;} else if((m[i] == 'c' && n[j] == 'x')||(m[i] == 'c' && n[j] == 'z')){ continue;} else if((m[i] == 'b' && n[j] == 'z')||(m[i] == 'b' && n[j] == 'y')){ continue;} else System.out.println(m[i] + “ vs ” + n[j]);} } } } 【程序19】
題目:打印出如下圖案(菱形)
* *** ***** ******* ***** *** * public class lianxi19 { public static void main(String[] args){ int H = 7, W = 7;//高和寬必須是相等的奇數
for(int i=0;i<(H+1)/ 2;i++){ for(int j=0;j 題目:有一分數序列:2/1,3/2,5/3,8/5,13/8,21/13...求出這個數列的前20項之和。public class lianxi20 { public static void main(String[] args){ int x = 2, y = 1, t;double sum = 0;for(int i=1;i<=20;i++){ sum = sum +(double)x / y;t = y;y = x;x = y + t;} System.out.println(“前20項相加之和是: ” + sum);} } 【程序21】 題目:求1+2!+3!+...+20!的和 public class lianxi21 { public static void main(String[] args){ long sum = 0; long fac = 1;for(int i=1;i<=20;i++){ fac = fac * i;sum += fac;} System.out.println(sum);} } 【程序22】 題目:利用遞歸方法求5!。public class lianxi22 { public static void main(String[] args){ int n = 5;rec fr = new rec();System.out.println(n+“!= ”+fr.rec(n));} } class rec{ public long rec(int n){ long value = 0;if(n ==1){ value = 1;} else { value = n * rec(n-1);} return value;} } 【程序23】 題目:有5個人坐在一起,問第五個人多少歲?他說比第4個人大2歲。問第4個人歲數,他說比第3個人大2歲。問第三個人,又說比第2人大兩歲。問第2個人,說比第一個人大兩歲。最后問第一個人,他說是10歲。請問第五個人多大? public class lianxi23 { public static void main(String[] args){ int age = 10;for(int i=2;i<=5;i++){ age =age+2;} System.out.println(age);} } 【程序24】 題目:給一個不多于5位的正整數,要求: 一、求它是幾位數,二、逆序打印出各位數字。//使用了長整型最多輸入18位 import java.util.*;public class lianxi24 { public static void main(String[] args){ Scanner s = new Scanner(System.in);System.out.print(“請輸入一個正整數:”);long a = s.nextLong();String ss = Long.toString(a);char[] ch = ss.toCharArray();int j=ch.length;System.out.println(a + “是一個”+ j +“位數。”);System.out.print(“按逆序輸出是:”);for(int i=j-1;i>=0;i--){ System.out.print(ch[i]);} } } 【程序25】 題目:一個5位數,判斷它是不是回文數。即12321是回文數,個位與萬位相同,十位與千位相同。 import java.util.*;public class lianxi25 { public static void main(String[] args){ Scanner s = new Scanner(System.in);int a;do{ System.out.print(“請輸入一個5位正整數:”);a = s.nextInt();}while(a<10000||a>99999);String ss =String.valueOf(a);char[] ch = ss.toCharArray();if(ch[0]==ch[4]&&ch[1]==ch[3]){ System.out.println(“這是一個回文數”);} else {System.out.println(“這不是一個回文數”);} } } //這個更好,不限位數 import java.util.*;public class lianxi25a { public static void main(String[] args){ Scanner s = new Scanner(System.in);boolean is =true;System.out.print(“請輸入一個正整數:”);long a = s.nextLong();String ss = Long.toString(a);char[] ch = ss.toCharArray();int j=ch.length;for(int i=0;i 判 else if(ch2 == 'A'){System.out.println(“Saturday”);} else {System.out.println(“無此寫法!”);} };break;default:System.out.println(“無此寫法!”);} } } class getChar{ public char getChar(){ Scanner s = new Scanner(System.in);String str = s.nextLine();char ch = str.charAt(0);if(ch<'A' || ch>'Z'){ System.out.println(“輸入錯誤,請重新輸入”);ch=getChar();} return ch;} } 【程序27】 題目:求100之內的素數 //使用除sqrt(n)的方法求出的素數不包括2和3 public class lianxi27 { public static void main(String[] args){ boolean b =false;System.out.print(2 + “ ”);System.out.print(3 + “ ”);for(int i=3;i<100;i+=2){ for(int j=2;j<=Math.sqrt(i);j++){ if(i % j == 0){b = false;break;} else{b = true;} } if(b == true){System.out.print(i + “ ”);} } } } //該程序使用除1位素數得2位方法,運行效率高通用性差。public class lianxi27a { public static void main(String[] args){ int[] a = new int[]{2, 3, 5, 7};for(int j=0;j<4;j++)System.out.print(a[j] + “ ”);boolean b =false;for(int i=11;i<100;i+=2){ for(int j=0;j<4;j++){ if(i % a[j] == 0){b = false;break;} else{b = true;} } if(b == true){System.out.print(i + “ ”);} } } } 【程序28】 題目:對10個數進行排序 import java.util.*;public class lianxi28 { public static void main(String[] args){ Scanner s = new Scanner(System.in);int[] a = new int[10];System.out.println(“請輸入10個整數:”);for(int i=0;i<10;i++){ a[i] = s.nextInt();} for(int i=0;i<10;i++){ for(int j=i+1;j<10;j++){ if(a[i] > a[j]){ int t = a[i];a[i] = a[j];a[j] = t;} } } for(int i=0;i<10;i++){ System.out.print(a[i] + “ ”);} } } 【程序29】 題目:求一個3*3矩陣對角線元素之和 import java.util.*;public class lianxi29 { public static void main(String[] args){ Scanner s = new Scanner(System.in);int[][] a = new int[3][3];System.out.println(“請輸入9個整數:”);for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ a[i][j] = s.nextInt();} } System.out.println(“輸入的3 * 3 矩陣是:”);for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ System.out.print(a[i][j] + “ ”);} System.out.println();} int sum = 0;for(int i=0;i<3;i++){ for(int j=0;j<3;j++){ if(i == j){ sum += a[i][j];} } } System.out.println(“對角線之和是:” + sum);} } 【程序30】 題目:有一個已經排好序的數組。現輸入一個數,要求按原來的規律將它插入數組中。//此程序不好,沒有使用折半查找插入 import java.util.*;public class lianxi30 { public static void main(String[] args){ int[] a = new int[]{1, 2, 6, 14, 25, 36, 37,55};int[] b = new int[a.length+1];int t1 =0, t2 = 0;int i =0;Scanner s= new Scanner(System.in);System.out.print(“請輸入一個整數:”);int num = s.nextInt();if(num >= a[a.length-1]){ b[b.length-1] = num;for(i=0;i 題目:將一個數組逆序輸出。import java.util.*;public class lianxi31 { public static void main(String[] args){ Scanner s = new Scanner(System.in);int a[] = new int[20];System.out.println(“請輸入多個正整數(輸入-1表示結束):”);int i=0,j;do{ a[i]=s.nextInt();i++;}while(a[i-1]!=-1);System.out.println(“你輸入的數組為:”);for(j=0;j 題目:取一個整數a從右端開始的4~7位。import java.util.*;public class lianxi32 { public static void main(String[] args){ Scanner s = new Scanner(System.in);System.out.print(“請輸入一個7位以上的正整數:”);long a = s.nextLong();String ss = Long.toString(a);char[] ch = ss.toCharArray();int j=ch.length;if(j<7){System.out.println(“輸入錯誤!”);} else { System.out.println(“截取從右端開始的”+ch[j-7]+ch[j-6]+ch[j-5]+ch[j-4]);} } } 【程序33】 題目:打印出楊輝三角形(要求打印出10行如下圖)1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 ………… public class lianxi33 { public static void main(String[] args){ int[][] a = new int[10][10];for(int i=0;i<10;i++){ a[i][i] = 1;a[i][0] = 1;} for(int i=2;i<10;i++){ for(int j=1;j 4~7位是:} 【程序34】 題目:輸入3個數a,b,c,按大小順序輸出。import java.util.Scanner;public class lianxi34 { public static void main(String[] args){ Scanner s = new Scanner(System.in);System.out.println(“請輸入3個整數:”);int a = s.nextInt();int b = s.nextInt();int c = s.nextInt();if(a < b){ int t = a;a = b;b = t;} if(a < c){ int t = a;a = c;c = t;} if(b < c){ int t = b;b = c;c = t;} System.out.println(“從大到小的順序輸出:”);System.out.println(a + “ ” + b + “ ” + c);} } 【程序35】 題目:輸入數組,最大的與第一個元素交換,最小的與最后一個元素交換,輸出數組。import java.util.*;public class lianxi35 { public static void main(String[] args){ int N = 8;int[] a = new int [N];Scanner s = new Scanner(System.in);int idx1 = 0, idx2 = 0;System.out.println(“請輸入8個整數:”);for(int i=0;i 題目:有n個人圍成一圈,順序排號。從第一個人開始報數(從1到3報數),凡報到3的人退出圈子,問最后留下的是原來第幾號的那位。import java.util.Scanner;public class lianxi37 { public static void main(String[] args){ Scanner s = new Scanner(System.in);System.out.print(“請輸入排成一圈的人數:”);int n = s.nextInt();boolean[] arr = new boolean[n];for(int i=0;i 題目:寫一個函數,求一個字符串的長度,在main函數中輸入字符串,并輸出其長度。/*……………… *……題目意思似乎不能用length()函數 */ import java.util.*;public class lianxi38 { public static void main(String[] args){ Scanner s = new Scanner(System.in);System.out.println(“請輸入一個字符串:”);String str = s.nextLine();System.out.println(“字符串的長度是:”+str.length());} } 【程序39】 題目:編寫一個函數,輸入n為偶數時,調用函數求1/2+1/4+...+1/n,當輸入n為奇數時,調用函數1/1+1/3+...+1/n(利用指針函數)//沒有利用指針函數 import java.util.*;public class lianxi39 { public static void main(String[] args){ Scanner s = new Scanner(System.in);System.out.print(“請輸入一個正整數 n= ”);int n = s.nextInt();System.out.println(“相應數列的和為:” + sum(n));} public static double sum(int n){ double res = 0;if(n % 2 == 0){ for(int i=2;i<=n;i+=2){ res +=(double)1 / i;} } else { for(int i=1;i<=n;i+=2){ res +=(double)1 / i;} } return res;} } 【程序40】 題目:字符串排序。public class lianxi40 { public static void main(String[] args){ int N=5;String temp = null;String[] s = new String[N];s[0] = “matter”;s[1] = “state”;s[2] = “solid”;s[3] = “liquid”;s[4] = “gas”;for(int i=0;i 題目:809*??=800*??+9*??+1 其中??代表的兩位數,8*??的結果為兩位數,9*??的結果為3位數。求??代表的兩位數,及809*??后的結果。 //題目錯了!809x=800x+9x+1 這樣的方程無解。去掉那個1就有解了。public class lianxi42 { public static void main(String[] args){ int a=809,b,i;for(i=10;i<13;i++){b=i*a;if(8*i<100&&9*i>=100)System.out.println(“809*”+i+“=”+“800*”+i+“+”+“9*”+i+“=”+b);} } } 【程序43】 題目:求0—7所能組成的奇數個數。//組成1位數是4個。//組成2位數是7*4個。//組成3位數是7*8*4個。//組成4位數是7*8*8*4個。//......public class lianxi43 { public static void main(String[] args){ int sum=4;int j;System.out.println(“組成1位數是 ”+sum+“ 個”);sum=sum*7;System.out.println(“組成2位數是 ”+sum+“ 個”);for(j=3;j<=9;j++){ sum=sum*8;System.out.println(“組成”+j+“位數是 ”+sum+“ 個”);} } } 【程序44】 題目:一個偶數總能表示為兩個素數之和。 //由于用除sqrt(n)的方法求出的素數不包括2和3,//因此在判斷是否是素數程序中人為添加了一個3。import java.util.*;public class lianxi44 { public static void main(String[] args){ Scanner s = new Scanner(System.in);int n,i;do{ System.out.print(“請輸入一個大于等于6的偶數:”);n = s.nextInt();} while(n<6||n%2!=0);//判斷輸入是否是>=6偶數,不是,重新輸入 fun fc = new fun();for(i=2;i<=n/2;i++){ if((fc.fun(i))==1&&(fc.fun(n-i)==1)){int j=n-i;System.out.println(n+“ = ”+i+“ + ”+j);} //輸出所有可能的素數對 } } } class fun{ public int fun(int a)//判斷是否是素數的函數 { int i,flag=0;if(a==3){flag=1;return(flag);} for(i=2;i<=Math.sqrt(a);i++){ if(a%i==0){flag=0;break;} else flag=1;} return(flag);//不是素數,返回0,是素數,返回1 } } //解法二 import java.util.*;public class lianxi44 { public static void main(String[] args){ Scanner s = new Scanner(System.in);int n;do{ System.out.print(“請輸入一個大于等于6的偶數:”);n = s.nextInt();} while(n<6||n%2!=0);//判斷輸入是否是>=6偶數,不是,重新輸入 for(int i=3;i<=n/2;i+=2){ if(fun(i)&&fun(n-i)){ System.out.println(n+“ = ”+i+“ + ”+(n-i));} //輸出所有可能的素數對 } } static boolean fun(int a){ //判斷是否是素數的函數 boolean flag=false;if(a==3){flag=true;return(flag);} for(int i=2;i<=Math.sqrt(a);i++){ if(a%i==0){flag=false;break;} else flag=true;} return(flag);} } 【程序45】 題目:判斷一個素數能被幾個9整除 //題目錯了吧?能被9整除的就不是素數了!所以改成整數了。import java.util.*;public class lianxi45 { public static void main(String[] args){ Scanner s = new Scanner(System.in);System.out.print(“請輸入一個整數:”);int num = s.nextInt();int tmp = num;int count = 0;for(int i = 0;tmp%9 == 0;){ tmp = tmp/9;count ++;} System.out.println(num+“ 能夠被 ”+count+“ 個9整除。”);} } 【程序46】 題目:兩個字符串連接程序 import java.util.*;public class lianxi46 { public static void main(String[] args){ Scanner s = new Scanner(System.in);System.out.print(“請輸入一個字符串:”);String str1 = s.nextLine();System.out.print(“請再輸入一個字符串:”);String str2 = s.nextLine();String str = str1+str2;System.out.println(“連接后的字符串是:”+str);} } 【程序47】 題目:讀取7個數(1—50)的整數值,每讀取一個值,程序打印出該值個數的*。import java.util.*;public class lianxi47 { public static void main(String[] args){ Scanner s = new Scanner(System.in);int n=1,num;while(n<=7){ do{ System.out.print(“請輸入一個1--50之間的整數:”);num= s.nextInt();}while(num<1||num>50);for(int i=1;i<=num;i++){System.out.print(“*”);} System.out.println();n ++;} } } 【程序48】 題目:某個公司采用公用電話傳遞數據,數據是四位的整數,在傳遞過程中是加密的,加密規則如下:每位數字都加上5,然后用和除以10的余數代替該數字,再將第一位和第四位交換,第二位和第三位交換。import java.util.*;public class lianxi48 { public static void main(String args[]){ Scanner s = new Scanner(System.in);int num=0,temp;do{ System.out.print(“請輸入一個4位正整數:”);num = s.nextInt();}while(num<1000||num>9999);int a[]=new int[4];a[0] = num/1000;//取千位的數字 a[1] =(num/100)%10;//取百位的數字 a[2] =(num/10)%10;//取十位的數字 a[3] = num%10;//取個位的數字 for(int j=0;j<4;j++){ a[j]+=5;a[j]%=10;} for(int j=0;j<=1;j++){ temp = a[j];a[j] = a[3-j];a[3-j] =temp;} System.out.print(“加密后的數字為:”);for(int j=0;j<4;j++)System.out.print(a[j]);} } 【程序49】 題目:計算字符串中子串出現的次數 import java.util.*;public class lianxi49 { public static void main(String args[]){ Scanner s = new Scanner(System.in);System.out.print(“請輸入字符串:”);String str1 = s.nextLine();System.out.print(“請輸入子串:”);String str2 = s.nextLine();int count=0;if(str1.equals(“")||str2.equals(”“)){ System.out.println(”你沒有輸入字符串或子串,無法比較!“);System.exit(0);} else { for(int i=0;i<=str1.length()-str2.length();i++){ if(str2.equals(str1.substring(i, str2.length()+i)))//這種比法有問題,會把”aaa“看成有2個”aa“子串。count++;} System.out.println(”子串在字符串中出現: “+count+” 次“);} } } 【程序50】 題目:有五個學生,每個學生有3門課的成績,從鍵盤輸入以上數據(包括學生號,姓名,三門課成績),計算出平均成績,把原有的數據和計算出的平均分數存放在磁盤文件 ”stud “中。 import java.io.*;import java.util.*;public class lianxi50 { public static void main(String[] args){ Scanner ss = new Scanner(System.in);String [][] a = new String[5][6];for(int i=1;i<6;i++){ System.out.print(”請輸入第“+i+”個學生的學號:“);a[i-1][0] = ss.nextLine();System.out.print(”請輸入第“+i+”個學生的姓名:“);a[i-1][1] = ss.nextLine();for(int j=1;j<4;j++){ System.out.print(”請輸入該學生的第“+j+”個成績:“);a[i-1][j+1] = ss.nextLine();} System.out.println(”n“);} //以下計算平均分 float avg;int sum;for(int i=0;i<5;i++){ sum=0;for(int j=2;j<5;j++){ sum=sum+ Integer.parseInt(a[i][j]);} avg=(float)sum/3;a[i][5]=String.valueOf(avg);} //以下寫磁盤文件 String s1;try { File f = new File(”C:stud“);if(f.exists()){ System.out.println(”文件存在“);}else{ System.out.println(”文件不存在,正在創建文件“);f.createNewFile();//不存在則創建 } BufferedWriter output = new BufferedWriter(new FileWriter(f));for(int i=0;i<5;i++){ for(int j=0;j<6;j++){ s1=a[i][j]+”rn“;output.write(s1);} } output.close();System.out.println(”數據已寫入c盤文件stud中!");} catch(Exception e){ e.printStackTrace();} } } 一、選擇題 1.Java中提供了名為()的包裝類來包裝原始字符串類型。A.Integer B.Char C.Double D.String 2.java.lang包的()方法比較兩個對象是否相等,相等返回true。A.toString()B.equals()C.compare() D.以上所有選項都不正確 3.下面的集合中,()不可以存儲重復元素。A.Set B.Collection C.Map D.List 4.Java接口的修飾符可以為() A private B protected C final D abstract 5.下面哪些是Thread類的方法() A start()B run()C exit()D getPriority() 6.下面關于java.lang.Exception類的說法正確的是() A 繼承自Throwable B Serialable C集成自Error D以上都不正確 7.下面程序的運行結果:() public static void main(String[] args){ // TODO Auto-generated method stub Thread t = new Thread(){ public void run(){ pong();} };t.run();System.out.print(“ping”);} static void pong(){ System.out.print(“pong”);} A pingpong B pongping C pingpong和pongping都有可能 D 都不輸出 8.下面哪個流類屬于面向字符的輸入流()A BufferedWriter B FileInputStream C ObjectInputStream D InputStreamReader 9.ArrayList list = new ArrayList(20);中的list擴充幾次() A 0 B 1 C 2 D 3 二、問答題 1.String與StringBuffer的區別? 2.談談final、finally、finalize的區別? 3.創建一個對象的方法有哪些? 4.編寫一個程序,產生ArrayIndexOutOfBoundsException異常,并捕獲該異常,在控制臺輸出異常信息。 5.寫一個線程安全的Singleton實例 6.請用JAVA代碼實現拷貝一個大于2G的文件到其他盤。 7.設計四個線程,其中兩個線程每次對變量i加1,另外兩個線程每次對i減1.8.自己編寫代碼,實現生產者-消費者模型功能.內容自由發揮,只需要表達思想.9.在Mysql中,請用一條SQL語句將現有的三條記錄復制一下,達到以下的效果: ID name pass aaa 111 bbb 222 ccc 333 aaa 111 bbb 222 ccc 333 10.用SQL語句刪除上一題的重復記錄.。 JAVA筆試題 ? 軟件開發工程師(JAVA)筆試題 請在90分鐘以內做答 答案請寫在答題紙上 一、選擇題 1、下面哪項是不合法的標識符:(c e)A.$persons B.TwoUsers C.*point D._endline E.final 2、下列運算符合法的是(a) A.&& B.<> C.if D.:= 3、下面描述中哪兩項相等:(bg)[選擇兩項] A.<%= YoshiBean.size%> B.<%= YoshiBean.getSize()%> C.<%= YoshiBean.getProperty(“size”)%> D. 4、設float x = 1,y = 2,z = 3,則表達式 y+=z--/++x的值是:(a)A.3.5 B.3 C.4 D.5 A.equals()方法判定引用值是否指向同一對象 B.==操作符判定兩個不同的對象的內容和類型是否一致 C.equal()方法只有在兩個對象的內容一致時返回true D.類File重寫方法equals()在兩個不同的對象的內容和類型一致時返回true 6、如果一個對象僅僅聲明實現了cloneable接口,但是不聲明clone方法,外部能夠調用其clone方法嗎?(b)A.能 B.不能 C.不確定 7、下列說法錯誤的有(bd) A. 能被java.exe成功運行的java class文件必須有main()方法 B. J2SDK就是Java API C. Appletviewer.exe可利用jar選項運行.jar文件 D. 能被Appletviewer成功運行的java class文件必須有main()方法 8、下列正確的有(acd) A. call by value不會改變實際參數的數值 B. call by reference能改變實際參數的參考地址 C. call by reference不能改變實際參數的參考地址 D. call by reference能改變實際參數的內容 9、下列說法錯誤的有(bcd) A. 數組是一種對象 B. 數組屬于一種原生類 C. int number=[]={31,23,33,43,35,63} 5、下面的哪些敘述為真:(d) D. 數組的大小可以任意改變 10、不能用來修飾interface的有(ad) JAVA筆試題 A.private B.public C.protected D.static 11、關于Float,下列說法正確的是(a) A.Float是一個類 B.Float在java.lang包中 C.Float a=1.0是正確的賦值方法 D.Float a= new Float(1.0)是正確的賦值方法 12、下列哪種說法是正確的(d) A. 實例方法可直接調用超類的實例方法 B. 實例方法可直接調用超類的類方法 C. 實例方法可直接調用其他類的實例方法 D. 實例方法可直接調用本類的類方法 13、下列說法錯誤的有(c) A.在類方法中可用this來調用本類的類方法 B.在類方法中調用本類的類方法時可直接調用 C.在類方法中只能調用本類中的類方法 D.在類方法中絕對不能調用實例方法 14、下面說法哪些是正確的? bd A.Applet可以訪問本地文件 B.對static方法的調用不需要類實例 C.socket類在java.lang中 D.127.0.0.1地址代表本機 1.public class Test1 { 2.public float aMethod(float a, float b)throws 3.IOException { } 4.} 5.public class Test2 extends Test1 { 6.//Line6 7.} 將以下(ac)方法插入行6是不合法的。 A.float aMethod(float a, float b){} B.public int aMethod(int a, int b)throws Exception {} C.public float aMethod(float P, float q){} D.public int aMethod(int a, int b)throws IOException {} 16、關于以下程序段,正確的說法是:(b) 1.String s1 = “abc” + “def”;2.String s2 = new String(s1);3.if(s1.equals(s2))4.System.out.println(“.equals()succeeded”);5.if(s1 == s2)6.System.out.println(“== succeeded”);A.行4與行6都將執行 B.行4執行,行6不執行 ?? 15、類Test1、Test2定義如下: C.行6執行,行4不執行 D.行 4、行6都不執行 JAVA筆試題 17、下面程序的執行結果為:(a) 1.public class Test { 2.static Boolean foo(char c){ 3.System.out.println(c);4.return true;5.} 6.public static void main(String[] args){ 7.int i = 0;8.for(foo(‘A’);foo(‘B’)&&(i<2);foo(‘C’)){ 9.i++;10.foo(‘D’);11.} 12.} 13.} A.ABDCBDCB B.ABCDABCD C.Compilation fails C.An exception is thrown at runtime 18、閱讀下面的程序 1.public class Outer { 2.public void someOuterMethod(){ 3.//Line3 4.} 5.public class Inner(){} 6.public static void main(String[] args){ 7.Outer o = new Outer();8.//Line8 9.} 10.} Which instantiates is an instance of Inner?(c) A.new Inner();// At line3 B.new Inner();// At line 8 C.new o.Inner();// At line 8 C.new Outer.inner();// At line 8 19、選出能正確賦值的: public class TestA { private int a;return m;public int change(int m){ } } public class TestB extend TestA{ public int b;public static void main(){ TestA aa = new TestA();int k; TestB bb = new TestB(); } } 在Line13處可以正確賦值的有:(d)// Line 13 JAVA筆試題 A.k= m;B.k=b;C.k=aa.a;D.k=bb.change(30);E.k=bb.a 20、已知如下代碼: switch(m){ case 0: System.out.println(“Condition 0”);case 1: System.out.println(“Condition 1”);case 2: System.out.println(“Condition 2”);case 3: System.out.println(“Condition 3”);break;default: System.out.println(“Other Condition”);} 當 m 的值為什么時輸出 “Condition 2”?(abc)A.0 B.1 C.2 D.3 E.4 F.None 21、給出程序段 public class Parent { public int addValue(int a,int b){ int s;s=a+b;return s;} } class Child extends Parent{} 可以加在Child類的方法有:(cd)A.int addValue(int a,int b){} B.public void addValue(int a,int b){} C.public int addValue(int a){} D.public int addValue(int a,int b){} 22、下述哪些說法是正確的?(d)A.實例變量是類的成員變量 B.實例變量是用static關鍵字聲明的 C.方法變量在方法執行時創建 D.方法變量在使用之前必須初始化 23、對于下列代碼: public class Sample{ long length; public Sample(long l){ length = l;} public static void main(String arg[]){ Sample s1, s2, s3; s1 = new Sample(21L); s2 = new Sample(21L); s3 = s2; long m = 21L; } } 下列哪些表達式返回值為'true'?(d) JAVA筆試題 A.s1 = = s2;B.s2 = = s3;C.m = = s1;D.s1.equals(m) 26、當 Frame 改變大小時,放在其中的按鈕大小不變,則使用如下哪個 layout?(e)A.FlowLayout B.CardLayout C.North and South of BorderLayout D.East and West of BorderLayout E.GridLayout 27、已知如下的命令執行 java MyTest a b c 請問哪個語句是正確的?(cd)A.args[0] = “MyTest a b c” B.args[0] = “MyTest” C.args[0] = “a” D.args[1]= “b” 28、下面哪個語句是創建數組的正確語句?(ab)A.float f[][] = new float[6][6];B.float []f[] = new float[6][6];C.float f[][] = new float[][6];D.float [][]f = new float[6][6];E.float [][]f = new float[6][];30、以下關于數據庫范式的描述,哪些是錯誤的(c) A.如果把多個數據項用一個大的 String 表示為一個字段,則不滿足 private String name;public String getName(){ return name;} public Ball(String name){ this.name = name;} public void play(){ ball = new Ball(“Football”); JAVA筆試題 System.out.println(ball.getName());} } 上面代碼是否有錯,如果有錯,錯誤在何處? 紅處 2、詳細解釋下面的語句: Class.class.getClass()Class與class繼承自Object,class試題來代表java運行時的class和interface等等 Class.class就是得到或者生成這個Class類的Class Object 而getClass()本身就是返回一個類對應的Class Object,所以最后Class.class.getClass()最后還是返回Class Object 7、編寫一個截取字符串的函數,輸入為一個字符串和字節數,輸出為按字節截取的字符串。但是要保證漢字不被截半個,如“我ABC”4,應該截為“我AB”,輸入“我ABC漢DEF”,應該輸出為“我ABC”而不是“我ABC+漢的半個”。 public static boolean isLetter(char c){ int k=0X80;return c/k==0?true:false;} public static int lengths(String strSrc){ if(strSrc==null){ return 0;} int len=0;char[] strChar=strSrc.toCharArray();for(int i=0;i JAVA筆試題 public static String subString(String origin,int len){ if(origin==null || origin.equals(“")|| len<1){ return ”“;} if(len>lengths(origin)){ return origin;} byte[] strByte=new byte[len];System.arraycopy(origin.getBytes(),0,strByte,0,len);int count=0;for(int i=0;i } public static void main(String[] args){ System.out.println(”“+ subString(”我ABC漢DEF",6));} 10、SQL問答題 表結構: 1、表名:g_cardapply 字段(字段名/類型/長度): g_applyno varchar 8: //申請單號(關鍵字)g_applydate bigint 8: //申請日期 g_state varchar 2: //申請狀態 2、表名:g_cardapplydetail 字段(字段名/類型/長度): g_applyno varchar 8: //申請單號(關鍵字)g_name varchar 30: //申請人姓名 g_idcard varchar 18: //申請人身份證號 g_state varchar 2: //申請狀態 其中,兩個表的關聯字為申請單號 題目: JAVA筆試題 1、查詢身份證號碼為***082的申請日期 2、查詢同一個身份證號碼有兩條以上記錄的身份證號碼及記錄個數 3、將身份證號碼為***082的記錄在兩個表中的申請狀態均改為07 4、刪除g_cardapplydetail表中所有姓李的記錄 1、select g_applydate from g_cardapply a,g_cardapplydetail b where a.g_applyno=b.g_applyno and b.g_idcard=’***082’ 2、select g_idcard,count(g_applyno)from g_cardapplydetail group by g_idcard having count(g_applyno)>2 3、update g_cardapply a,g_cardapplydetail b set a.g_state=’07’,b.g_state=’07’ where a.g_applyno=b.applyno and b.g_idcard=’ ***082’ 4、delete from g_cardapplydetail where g_name like ‘李%’ Java軟件開發工程師筆試題 一、選擇題(25 x 2’ = 50’) 1、一個Java程序運行從上到下的環境次序是() A. 操作系統、Java程序、JRE/JVM、硬件 B. JRE/JVM、Java程序、硬件、操作系統 C. Java程序、JRE/JVM、操作系統、硬件 D. Java程序、操作系統、JRE/JVM、硬件 2、下面代碼中的第2行可以插入一行代碼()保證程序編譯通過。 1、public interface A{ 2、3、} A.void method();B.public void method();C.static void method();D.private void method();E.protected void method(); 3、關于異常下列描述中,錯誤的是() A.異常機制可以用于流程控制 B.finally代碼段在發生異常時不一定必須執行 C.在catch代碼段中可以使用return語句來返回到異常拋出點 D.可以把catch到的異常對象再次拋出,使上層try—catch結構繼續處理該異常事件 4、關于被私有訪問控制符private修飾的成員變量,以下說法正確的是() A. 可以被三種類所引用:該類自身、與它在同一個包中的其他類、在其他包中的該類的子類 B. 可以被兩種類訪問和引用:該類本身、該類的所有子類 C. 只能被該類自身所訪問和修改 D. 只能被同一個包中的類訪問 5、某類Example的main()方法參數為args,當命令行中輸入Java Example cat時,args[0]的值為()。 A. cat B. Java C. example D. null 6、下面關于Thread類提供的現成控制方法的說法中,錯誤的是() A. 在線程A中執行現成B的join方法,則線程A等待直到線程B執行完成。B. 線程A通過調用iterrupt方法來中斷其阻塞狀態 C. 若線程A調用方法isAlive返回值為true,則說明A正在執行中 D. currentThread方法返回當前線程的引用 7、類Test1定義如下: 1.public class Test1{ 2. public float aMethod(float a,float b){ } 1/10 3.4.} 將以下哪種方法插入行3是不合法的。() A. public float aMethod(float a,float b,float c){ } B. public float aMethod(float c,float d){ } C. public int aMethod(int a,int b){ } D. private float aMethod(int a,int b,int c){ } 8、下面程序的輸出結果是()private static void foo(){ try { System.out.println(“try”);foo();} catch(Throwable e){ System.out.println(“catch”);foo();} finally { System.out.println(“finally”);foo();} } public static void main(String[] args){ foo();} A.執行一段時間后報棧溢出。B.會一直輸出“try”。 C.會一直輸出“try”和“finally”。D.會一直輸出“try”、“catch”和“finally” 9、下面的哪些程序片斷可能導致錯誤?()A.String s = “Gone with the wind”;String t = “ good ”;String k = s + t; B.String s = “Gone with the wind”;String t;t = s[3] + “one”; C.String s = “Gone with the wind”;String standard = s.toUpperCase(); D.String s = “home directory”;String t = s-“directory”; 10、已知如下代碼: 2/10 1: class Example{ 2: String str;3: public Example(){ 4: 5: } 6: public Example(String s){ 7: 8: } 9:} 10: class Demo extends Example{ 11: } 12: public class Test{ 13: public void f(){ 14: 15: 16: } } 哪句語句會導致錯誤?()A、line 3 B、line 6 C、line 10 D、line 14 E、line 15 11、下面的代碼中第4行創建的對象在什么時候符合垃圾回收的條件() 1、class Bar { } 2、class Test { 3、Bar doBar(){ 4、Bar b = new Bar(); 5、return b; 6、} 7、public static void main(String args[]){ 8、Test t = new Test(); 9、Bar newBar = t.doBar();10、11、12、newBar = new Bar();} } Example ex = new Example(“Good”);Demo d = new Demo(“Good”);str=s;str= “example”;A.程序運行第9行之后。B.程序運行第10行之后。C.doBar方法運行結束之后。D.main方法運行結束之后。 12、下列關于for循環和while循環的說法中哪個是正確的?() A. while循環能實現的操作,for循環也都能實現 B. while循環判斷條件一般是程序結果,for循環判斷條件一般是非程序結果 3/10 C. 兩種循環任何時候都可替換 D. 兩種循環結構中都必須有循環體,循環體不能為空 13、下述說法中,錯誤的是()A.Java中,方法的重載是指多個方法可以共享同一個名字 B.Java中,用abstract修飾的類稱為抽象類,它不能實例化 C.Java中,接口不包含成員變量和方法實現 D.Java中,構造方法可以有返回值 14、下面哪些是正確的() 11.class ClassA {} 22.ClassB p1 = new ClassB();23.ClassC p2 = new ClassC();24.ClassA p3 = new ClassB();25.ClassA p4 = new ClassC();12.class ClassB extends ClassA {} 13.class ClassC extends ClassA {} and: 21.ClassA p0 = new ClassA();A.p0 = p1; 15、以下代碼片段,正確的結果是:() 11.classA { 17.throw new IOException(); 18.} } 19.public static void main(String[] args){ 20.try { new B().process();} 21.catch(IOException e){ 22.System.out.println(”Exception”);} } 12.public void process(){ System.out.print(”A,”);} } 13.class B extends A { 15.super.process();A.Exception B.A,B,Exception C.Compilation fails because of an error in line 20.D.Compilation fails because of an error in line 14.E.A NullPointerException is thrown at runtime.16、用直接插入排序方法對下面四個序列進行排序(由小到大),元素比較次數最少的是()。 A. 94,32,40,90,80,46,21,69 B. 32,40,21,46,69,94,90,80 C. 21,32,46,40,80,69,90,94 D. 90,69,80,46,21,32,94,40 17、設棧最大長度為3,入棧順序為1,2,3,4,5,6,則不可能的出棧序列是() A.1,2,3,4,5,6 B.2,1,3,4,5,6 C.3,4,2,1,5,6 D.4,3,2,1,5,6 18、設有98個已排序列元素,采用二分法查找時,最大比較次數是() A.49 B.15 C.20 D.7 4/10 14.public void process()throws IOException { 16.System.out.print(”B,”);B.p1 =p2; C.p2 = p4; F.p2 =(ClassC)p4;D.p2 =(ClassC)p1;E.p1 =(ClassB)p3; 19、若一棵二叉樹具有10個度為2的結點,5個度為1的結點,則度為0的結點個數是() A.9 B.11 C.15 D.不確定 20、以下與數據的存儲結構無關的術語是()。 A.循環隊列 B.鏈表 C.哈希表 D.棧 21、設數組A[10?100,20?100]以行優先的方式順序存儲,每個元素占4個字節,且已知A[10,20]的地址為 1000,則A[50,90]的地址是() A.13240 B.14250 C.24220 D.14240 22、鏈表不具有的特點是() A.插入、刪除不需要移動元素 B.可隨機訪問任一元素 C.不必事先估計存儲空間 D.所需空間與線性長度成正比 23、下面關于線性表的敘述中,錯誤的是哪一個?() A.線性表采用順序存儲,必須占用一片連續的存儲單元。B.線性表采用順序存儲,便于進行插入和刪除操作。C.線性表采用鏈接存儲,不必占用一片連續的存儲單元。D.線性表采用鏈接存儲,便于插入和刪除操作。 24、若一個棧的輸入序列為1,2,3,?,n,輸出序列的第一個元素是i,則第j個輸出元素是()。A.i-j-1 B.i-j C.j-i+1 D.不確定的 25、下列說法不正確的是()。 A.圖的遍歷是從給定的源點出發每一個頂點僅被訪問一次 B.圖的深度遍歷不適用于有向圖 C.遍歷的基本算法有兩種:深度遍歷和廣度遍歷 D.圖的深度遍歷是一個遞歸過程 二、程序改錯(5 * 2’ = 10’)1.----public class Unbelievable { static Integer i;public static void main(String[] args){ } } if(i == 42)System.out.println(“Unbelievable”);2.—————————————————————————————————— class Animal { public String noise(){ 5/10 龍通科技有限公司筆試題 } class Dog extends Animal { } class Cat extends Animal { } public class Test { } public static void main(String[] args){ } Animal animal = new Dog();Cat cat =(Cat)animal;cat.noise();public String noise(){ } return “meow”;public String noise(){ } return “bark”;} return “peep”;3.—————————————————————————————————————— abstract class Something { } private abstract String doSomething();4.—————————————————————————————————————— public class Something { } class Other { } public int i;public static void main(String[] args){ } public void addOne(final Other o){ } o.i++;Other o = new Other();new Something().addOne(o);5.—————————————————————————————————————— class Something { final int i;public void doSomething(){ System.out.println(“i = ” + i);6 龍通科技有限公司筆試題 } } 三、程序閱讀題(每空2’,共 40’) 1、閱讀以下java代碼,寫出運行結果 class StaticTest { } 2、編寫將一維數組a[]中互不相同的數按從小到大順序重新存于一維數組a[]的程序。 class A{ public static void main(String[] args){ } for(j=0;j } System.out.prinln(a[j]);int a[]={15,7,15,6,4,3,4,6,7};int i,j,k,low,high,mid,t;for(i=k=1;i static int x=1;int y;StaticTest(){ } public static void main(String args[ ]){ StaticTest st=new StaticTest();System.out.println(“x=” + x);System.out.println(“st.y=” + st.y);st=new StaticTest();System.out.println(“st.y=” + st.y); } static { x++;} y++; 龍通科技有限公司筆試題 } 3、請用JAVA編寫如下程序:此程序處理一個由0和非0數字成員組成的數組(長度自定),例如0 0 1 2 0 1 0 0 0 1 0 0 0 0 0 2 0 7 8 9 0 0 1 2 3 4,把數組中所有連續兩個以上的0去掉,將結果存入一個新數組。如上例處理后結果為,1 2 0 1 1 2 0 7 8 9 1 2 3 4。public static void main(String[] args){ int[] srcArray = {0,0,1,2,0,1,0,0,0,1,0,0,0,0,0,2,0,7,8,9,0,0,1,2,3,4};int[] destArray = new int[50];int i=0,j=0,count=0;for(i=0;i } } for(i=0;i public static void main(String[] args){ } public static int Keeper(int peo, int n){ int k = 0;int peo;System.out.println(“請輸入人數:”);Scanner inp = new Scanner(System.in);peo = inp.nextInt();int k = Keeper(peo, 3);System.out.println(“最后留下的是 ” + k + “ 號!”); 4、有n個人圍成一圈,順序排號。從第一個人開始報數(從1到3報數),凡報到3的人退出圈子,再從他的下一 8 龍通科技有限公司筆試題 int[] array = new int[peo];for(int i = 1;i < peo;i++){ } for(k = 0;k < peo;k++){ } return k + 1;if(array[k] == 0){ } 4 ; ○int j = 1;while(j <= n){ } if(○1){ } if(j == n){ } j++;3 ; ○ ; ○j--; } } 5、在一個n×n的棋盤上,放置n個不能互相捕捉的國際象棋“皇后”的所有布局。以下是n皇后的算法,請完成填空部分: public class Queen { Queen(int d){ } // 放置皇后的方法 public void place(int row){ int i = 0;if(row == n){ 1 ; ○n = d;queenPos = new int[d];private int n;private int[] queenPos;private double num = 0;// 記錄共有多少種擺法 } else { 9 龍通科技有限公司筆試題 } // 判斷布局是否合法 private boolean legality(int list){ } // 測試方法 public static void main(String[] args){ }} System.out.println(“輸入個數n:”);Scanner in = new Scanner(System.in);int n = in.nextInt();try { } Queen q = new Queen(n);q.place(0);System.out.println(n + “*” + n + “時,” + “共有” + q.num + “種可能擺法。”);System.out.println(“OK!”);e.printStackTrace();if(list == 0) } return true;return true;if(queenPos[i] == queenPos[list])3 ; ○for(int i = 0;i < list;i++){ } for(i = 0;i < n;i++){ } queenPos[row] = i;if(legality(row)); ○if(○4)return false;} catch(Exception e){ 10 軟件開發工程師(JAVA)筆試題 請在120分鐘以內做答 一、選擇題 1、下面哪項是不合法的標識符:() A.$persons B.TwoUsers C.*point D._endline E.final 2、下列運算符合法的是() A.&& B.<> C.if D.:= 3、下面描述中哪兩項相等:()[選擇兩項] A.<%= YoshiBean.size%> B.<%= YoshiBean.getSize()%> C.<%= YoshiBean.getProperty(“size”)%> D. 4、設float x = 1,y = 2,z = 3,則表達式 y+=z--/++x的值是:()A.3.5 B.3 C.4 D.5 5、下面的哪些敘述為真:() A.equals()方法判定引用值是否指向同一對象 B.==操作符判定兩個不同的對象的內容和類型是否一致 C.equal()方法只有在兩個對象的內容一致時返回true D.類File重寫方法equals()在兩個不同的對象的內容和類型一致時返回true 6、如果一個對象僅僅聲明實現了cloneable接口,但是不聲明clone方法,外部能夠調用其clone方法嗎?() A.能 B.不能 C.不確定 7、下列說法錯誤的有() A. 能被java.exe成功運行的java class文件必須有main()方法 B. J2SDK就是Java API C. Appletviewer.exe可利用jar選項運行.jar文件 D. 能被Appletviewer成功運行的java class文件必須有main()方法 8、下列正確的有() A. call by value不會改變實際參數的數值 B. call by reference能改變實際參數的參考地址 C. call by reference不能改變實際參數的參考地址 D. call by reference能改變實際參數的內容 9、下列說法錯誤的有()A. 數組是一種對象 B. 數組屬于一種原生類 C. int number=[]={31,23,33,43,35,63} D. 數組的大小可以任意改變 10、不能用來修飾interface的有() A.private B.public C.protected D.static 11、關于Float,下列說法正確的是 A.Float是一個類 B.Float在java.lang包中 C.Float a=1.0是正確的賦值方法 D.Float a= new Float(1.0)是正確的賦值方法 12、下列哪種說法是正確的()A. 實例方法可直接調用超類的實例方法 B. 實例方法可直接調用超類的類方法 C. 實例方法可直接調用其他類的實例方法 D. 實例方法可直接調用本類的類方法 13、下列說法錯誤的有() A.在類方法中可用this來調用本類的類方法 B.在類方法中調用本類的類方法時可直接調用 C.在類方法中只能調用本類中的類方法 D.在類方法中絕對不能調用實例方法 14、下面說法哪些是正確的? A.Applet可以訪問本地文件 B.對static方法的調用不需要類實例 C.socket類在java.lang中 D.127.0.0.1地址代表本機 15、類Test1、Test2定義如下: 1.public class Test1 { 2.public float aMethod(float a, float b)throws 3.IOException { } 4.} 5.public class Test2 extends Test1 { 6.//Line6 7.} 將以下()方法插入行6是不合法的。A.float aMethod(float a, float b){} B.public int aMethod(int a, int b)throws Exception {} C.public float aMethod(float P, float q){} D.public int aMethod(int a, int b)throws IOException {} 16、關于以下程序段,正確的說法是:()1.String s1 = “abc” + “def”;2.String s2 = new String(s1);3.if(s1.equals(s2))4.System.out.println(“.equals()succeeded”);5.if(s1 == s2)6.System.out.println(“== succeeded”); A.行4與行6都將執行 B.行4執行,行6不執行 C.行6執行,行4不執行 D.行 4、行6都不執行 17、下面程序的執行結果為:()1.public class Test { 2.static Boolean foo(char c){ 3.System.out.println(c);4.return true;5.} 6.public static void main(String[] args){ 7.int i = 0;8.for(foo(‘A’);foo(‘B’)&&(i<2);foo(‘C’)){ 9.i++;10.foo(‘D’);11.} 12.} 13.} A.ABDCBDCB B.ABCDABCD C.Compilation fails C.An exception is thrown at runtime 18、閱讀下面的程序 1.public class Outer { 2.public void someOuterMethod(){ 3.//Line3 4.} 5.public class Inner(){} 6.public static void main(String[] args){ 7.Outer o = new Outer();8.//Line8 9.} 10.} Which instantiates is an instance of Inner?() A.new Inner();// At line3 B.new Inner();// At line 8 C.new o.Inner();// At line 8 C.new Outer.inner();// At line 8 19、選出能正確賦值的: public class TestA { private int a;public int change(int m){ return m;} } public class TestB extend TestA{ public int b;public static void main(){ TestA aa = new TestA();TestB bb = new TestB();int k;// Line 13 } } 在Line13處可以正確賦值的有:() A.k= m;B.k=b;C.k=aa.a;D.k=bb.change(30);E.k=bb.a 20、已知如下代碼: switch(m){ case 0: System.out.println(“Condition 0”);case 1: System.out.println(“Condition 1”);case 2: System.out.println(“Condition 2”);case 3: System.out.println(“Condition 3”);break;default: System.out.println(“Other Condition”);} 當 m 的值為什么時輸出 “Condition 2”?()A.0 B.1 C.2 D.3 E.4 F.None 21、給出程序段 public class Parent { public int addValue(int a,int b){ int s;s=a+b;return s;} } class Child extends Parent{} 可以加在Child類的方法有:()A.int addValue(int a,int b){} B.public void addValue(int a,int b){} C.public int addValue(int a){} D.public int addValue(int a,int b){} 22、下述哪些說法是正確的?()A.實例變量是類的成員變量 B.實例變量是用static關鍵字聲明的 C.方法變量在方法執行時創建 D.方法變量在使用之前必須初始化 23、對于下列代碼: public class Sample{ long length;public Sample(long l){ length = l;} public static void main(String arg[]){ Sample s1, s2, s3;s1 = new Sample(21L);s2 = new Sample(21L);s3 = s2;long m = 21L;} } 下列哪些表達式返回值為'true'?()A.s1 = = s2;B.s2 = = s3;C.m = = s1;D.s1.equals(m) 24、哪個類可用于處理 Unicode? A.InputStreamReader B.BufferedReader C.Writer D.PipedInputStream 25、已知如下說明: TextArea ta = new TextArea(“Hello”, 5, 5);請問哪個語句是正確的?()A.The maximum number of characters in a line is 5.B.The displayed height is 5 lines otherwise constrain.C.The displayed string can use multiple fonts.D.The displayed strings are editable.26、當 Frame 改變大小時,放在其中的按鈕大小不變,則使用如下哪個 layout?()A.FlowLayout B.CardLayout C.North and South of BorderLayout D.East and West of BorderLayout E.GridLayout 27、已知如下的命令執行 java MyTest a b c 請問哪個語句是正確的?()A.args[0] = “MyTest a b c” B.args[0] = “MyTest” C.args[0] = “a” D.args[1]= “b” 28、下面哪個語句是創建數組的正確語句?()A.float f[][] = new float[6][6];B.float []f[] = new float[6][6];C.float f[][] = new float[][6];D.float [][]f = new float[6][6];E.float [][]f = new float[6][]; 29、下面敘述那些是正確的?() A:java中的集合類(如Vector)可以用來存儲任何類型的對象,且大小可以自動調整。但需要事先知道所存儲對象的類型,才能正常使用。B:在java中,我們可以用違例(Exception)來拋出一些并非錯誤的消息,但這樣比直接從函數返回一個結果要更大的系統開銷。C:java接口包含函數聲明和變量聲明。 D:java中,子類不可以訪問父類的私有成員和受保護的成員。30、以下關于數據庫范式的描述,哪些是錯誤的() A.如果把多個數據項用一個大的 String 表示為一個字段,則不滿足第一范式 B.滿足數據庫范式使得數據庫的效率更高 C.如果滿足更高的范式,則必須首先滿足低級別的范式 D.數據庫第二范式要求把表中與所有鍵沒有直接關系的數據全部拆分到其他表中 31、在Hibernate中, 32、以下程序代碼對Customer的name屬性修改了兩次: tx = session.beginTransaction();Customer customer=(Customer)session.load(Customer.class, new Long(1));customer.setName(“Jack”);customer.setName(“Mike”);tx.commit();執行以上程序,Hibernate需要向數據庫提交幾條update語句?()A.0 B.1 C.2 D.3 33、假設對Customer類的orders集合采用延遲檢索策略,編譯或運行以下程序,會出現什么情況?() Session session=sessionFactory.openSession();tx = session.beginTransaction();Customer customer=(Customer)session.get(Customer.class,new Long(1));tx.commit();session.close();Iterator orderIterator=customer.getOrders().iterator();A.編譯出錯 B.編譯通過,并正常運行 C.編譯通過,但運行時拋出異常 34、設棧最大長度為 3,入棧序列為 1,2,3,4,5,6,則不可能得出棧序列是() A.1,2,3,4,5,6 B.2,1,3,4,5,6 C.3,4,2,1,5,6 D.4,3,2,1,5,6 35、在 UML 方法中,使用多種類型的圖形來幫助進行設計,請問一下那些圖形不是 UML 的圖形類型() A.類圖 B.實體關系圖 C.序列圖 D.活動圖 二、問答題 1、閱讀下面的代碼 interface Playable { void play();} interface Bounceable { void play();} interface Rollable extends Playable, Bounceable { Ball ball = new Ball(“PingPang”);} class Ball implements Rollable { private String name;public String getName(){ return name;} public Ball(String name){ this.name = name;} public void play(){ ball = new Ball(“Football”);System.out.println(ball.getName());} } 上面代碼是否有錯,如果有錯,錯誤在何處? 2、詳細解釋下面的語句: Class.class.getClass() 3、解釋一下什么是MVC,IOC,AOP,ORM,JNDI,,Hibernate,SSO、Portal? 4、什么是EJB?EJB和JAVA BEAN有何區別? 5、現有Mysql數據庫,寫Spring + Hibernate的配置文件 數據IP:127.0.0.1 數據庫:bdtc 用戶名:root 密碼:mysql 6、請簡要描述一下J2EE應用中的class loader的層次結構? 7、編寫一個截取字符串的函數,輸入為一個字符串和字節數,輸出為按字節截取的字符串。但是要保證漢字不被截半個,如“我ABC”4,應該截為“我AB”,輸入“我ABC漢DEF”,應該輸出為“我ABC”而不是“我ABC+漢的半個”。 8、XML 的解析技術有哪些?區別是什么?你在項目中用到了xml技術的哪些方面?如何實現的? 9、寫一段代碼,實現銀行轉帳功能: 接口定義如下: Public interface ITransfer{ /** * 銀行內部轉帳,從轉出帳號中扣除轉帳金額,給轉入帳號增加轉帳金額,需要保證以上兩個操作 * 要么同時成功,要么同時失敗 * fromAccountId 轉出帳號 * outAccountId 轉入帳號 * amount 轉帳金額 **/ Public void transferInner(String fromAccountId,String outAccountId, BigDecimal amount);/** * 外部轉帳-轉出,從轉出帳號中扣除轉帳金額 * fromAccountId 轉出帳號 * amount 轉帳金額 **/ Public void transferOut(String fromAccountId,BigDecimal amount);/** * 外部轉帳-轉入,給轉入帳號增加轉帳金額 * toAccountId 轉入帳號 * amount 轉帳金額 Public void transerIn(String toAccountId, BigDecimal amount);} 請編寫你的實現類,來實現上述接口 Account表 字段:accountId , 主鍵 varchar2(32), 用戶帳號 字段:amount , 金額 number(18,3) 10、SQL問答題 表結構: 1、表名:g_cardapply 字段(字段名/類型/長度): g_applyno varchar 8: //申請單號(關鍵字)g_applydate bigint 8: //申請日期 g_state varchar 2: //申請狀態 2、表名:g_cardapplydetail 字段(字段名/類型/長度): g_applyno varchar 8: //申請單號(關鍵字)g_name varchar 30: //申請人姓名 g_idcard varchar 18: //申請人身份證號 g_state varchar 2: //申請狀態 其中,兩個表的關聯字為申請單號 題目: 1、查詢身份證號碼為***082的申請日期 2、查詢同一個身份證號碼有兩條以上記錄的身份證號碼及記錄個數 3、將身份證號碼為***082的記錄在兩個表中的申請狀態均改為07 4、刪除g_cardapplydetail表中所有姓李的記錄第二篇:JAVA工程師筆試題
第三篇:軟件開發工程師(JAVA)筆試題A
第四篇:Java軟件開發工程師筆試題
第五篇:軟件開發工程師(JAVA)筆試題