第一篇:java筆試題06
Using the java.lang.String Class 1.Given the following, 1.public class StringRef { 2.public static void main(String [] args){ 3.String s1 = “abc”;4.String s2 = “def”;5.String s3 = s2;6.s2 = “ghi”;7.System.out.println(s1 + s2 + s3);8.} 9.} what is the result? A.abcdefghi B.abcdefdef C.abcghidef D.abcghighi E.Compilation fails.F.An exception is thrown at runtime.2.Given the following, 11.String x = “xyz”;12.x.toUpperCase();13.String y = x.replace('Y', 'y');14.y = y + “abc”;15.System.out.println(y);what is the result? A.abcXyZ B.abcxyz C.xyzabc D.XyZabc E.Compilation fails.F.An exception is thrown at runtime.3.Given the following, 13.String x = new String(“xyz”);生成兩個字符串 14.String y = “abc”;15.x = x + y;how many String objects have been created? A.2 B.3 C.4 D.5 4.Given the following, 14.String a = “newspaper”;15.a = a.substring(5,7);substring截字符串的,截取到end-1 的位置 16.char b = a.charAt(1);charAt他是截取單個字符,從0開始 17.a = a + b;18.System.out.println(a);what is the result? A.apa B.app C.apea D.apep E.papp F.papa 5.Given the following, 4.String d = “bookkeeper”;5.d.substring(1,7);6.d = “w” + d;7.d.append(“woo”);String類沒有append()方法 8.System.out.println(d);what is the result? A.wookkeewoo B.wbookkeeper C.wbookkeewoo D.wbookkeeperwoo E.Compilation fails.F.An exception is thrown at runtime.Using the java.lang.Math Class 6.Given the following, 1.public class Example { 2.public static void main(String [] args){ 3.double values[] = {-2.3,-1.0, 0.25, 4};4.int cnt = 0;5.for(int x=0;x < values.length;x++){ 6.if(Math.round(values[x] +.5)== Math.ceil(values[x])){ 7.++cnt;8.} 9.} 10.System.out.println(“same results ” + cnt + “ time(s)”);11.} 12.} what is the result? Round:四舍五入
Math.round(11.6)= 12 Math.round(-11.6)=-12 Ceil:向上取整
Math.ceil(x)>= Floor:向下取整
Math.floor(x)<= x A.same results 0 time(s)B.same results 2 time(s)C.same results 4 time(s)D.Compilation fails.E.An exception is thrown at runtime.7.Which of the following are valid calls to Math.max?(Choose all that apply.)(Yeah, yeah, we know that on the real exam you’d know how many were correct, but we just want you to work a little harder here.)A.Math.max(1,4)B.Math.max(2.3, 5)C.Math.max(1, 3, 5, 7)D.Math.max(-1.5,-2.8f)8.What two statements are true about the result obtained from calling Math.random()?(Choose two.)Math.random()返回【0,1)的數,無盡接近于1; A.The result is less than 0.0.B.The result is greater than or equal to 0.0..C.The result is less than 1.0.D.The result is greater than 1.0.E.The result is greater than or equal to 1.0.F.The result is less than or equal to 1.0.9.Given the following, 1.public class SqrtExample { 2.public static void main(String [] args){ 3.double value =-9.0;4.System.out.println(Math.sqrt(value));5.} 6.} what is the result? Math.sqrt():他是開平方的,double的負數開平方的結果是NaN; A.3.0 B.–3.0 C.NaN D.Compilation fails.E.An exception is thrown at runtime.10.Given the following, 1.public class Degrees { 2.public static void main(String [] args){ 3.System.out.println(Math.sin(75));Math.sin(double x)//x是弧度數 4.System.out.println(Math.toDegrees(Math.sin(75)));是弧度數5.System.out.println(Math.sin(Math.toRadians(75)));將參數制定的弧度轉換為對
應的角度
6.System.out.println(Math.toRadians(Math.sin(75)));將參數的角度數轉換成弧度 7.} 8.} at what line will the sine of 75 degrees be output? A.Line 3 B.Line 4 C.Line 5 D.Line 6 E.Line 3 and either line 4, 5, or 6 F.None of the above Using Wrapper Classes 要使用1.4版本
11.Given the following, 1.public class WrapTest2 { 2.public static void main(String [] args){ 3.Long b = new Long(42);4.int x = Integer.valueOf(“345”);5.int x2 =(int)Integer.parseInt(“345”, 8);6.int x3 = Integer.parseInt(42);7.int x4 = Integer.parseInt(“42”);8.int x5 = b.intValue();9.} 10.} which two lines will cause compiler errors?(Choose two.)A.Line 3 B.Line 4 C.Line 5 D.Line 6 E.Line 7 F.Line 8 12.Given the following, 1.public class NFE { 2.public static void main(String [] args){ 3.String s = “42”;4.try { 5.s = s.concat(“.5”);6.double d = Double.parseDouble(s);7.s = Double.toString(d);8.int x =(int)Math.ceil(Double.valueOf(s).doubleValue());9.System.out.println(x);10.} 11.catch(NumberFormatException e){ 12.System.out.println(“bad number”);13.} 14.} 15.} what is the result? A.42 B.42.5 C.43 D.bad number E.Compilation fails.F.An uncaught exception is thrown at runtime.13.Given the following, 1.public class BoolTest { 2.public static void main(String [] args){ 3.Boolean b1 = new Boolean(“false”);4.boolean b2;5.b2 = b1.booleanValue();6.if(!b2){ 7.b2 = true;8.System.out.print(“x ”);9.} 10.if(b1 & b2){ //Boolean & boolean是不可以的 11.System.out.print(“y ”);12.} 13.System.out.println(“z”);14.} 15.} what is the result? A.z B.x z C.y z D.x y z E.Compilation fails.F.An exception is thrown at runtime.14.Given the following, 1.public class WrapTest3 { 2.public static void main(String [] args){ 3.String s = “98.6”;4.// insert code here 5.} 6.} which three lines inserted independently at line 4 will cause compiler errors?(Choose three.)A.float f1 = Float.floatValue(s);floatValue 是非static 的 B.float f2 = Float.valueOf(s);valueOf()返回是Float類型的 C.float f3 = new Float(3.14f).floatValue();D.float f4 = Float.parseFloat(1.23f);parseFloat(String)參數的String E.float f5 = Float.valueOf(s).floatValue();F.float f6 =(float)Double.parseDouble(“3.14”);15.Given the following, 11.try { 12.Float f1 = new Float(“3.0”);13.int x = f1.intValue();14.byte b = f1.byteValue();15.double d = f1.doubleValue();16.System.out.println(x + b + d);17.} 18.catch(NumberFormatException e){ 19.System.out.println(“bad number”);20.} what is the result? A.9.0 B.bad number C.Compilation fails on line 13.D.Compilation fails on line 14.E.Compilation fails on lines 13 and 14.F.An uncaught exception is thrown at runtime.Using equals()16.Given the following, 1.public class WrapTest { 2.public static void main(String [] args){ 3.int result = 0;4.short s = 42;5.Long x = new Long(“42”);6.Long y = new Long(42);7.Short z = new Short(“42”);8.Short x2 = new Short(s);9.Integer y2 = new Integer(“42”);10.Integer z2 = new Integer(42);11.12.if(x == y)result = 1;13.if(x.equals(y))result = result + 10;14.if(x.equals(z))result = result + 100;15.if(x.equals(x2))result = result + 1000;16.if(x.equals(z2))result = result + 10000;17.18.System.out.println(“result = ” + result);19.} 20.} what is the result? A.result = 1 B.result = 10 C.result = 11 D.result = 11010 E.result = 11011 F.result = 11111 17.Given the following, 1.public class BoolTest { 2.public static void main(String [] args){ 3.int result = 0;4.5.Boolean b1 = new Boolean(“TRUE”);6.Boolean b2 = new Boolean(“true”);7.Boolean b3 = new Boolean(“tRuE”);8.Boolean b4 = new Boolean(“false”);9.10.if(b1 == b2)result = 1;11.if(b1.equals(b2))result = result + 10;12.if(b2 == b4)result = result + 100;13.if(b2.equals(b4))result = result + 1000;14.if(b2.equals(b3))result = result + 10000;15.16.System.out.println(“result = ” + result);17.} 18.} what is the result? A.0 B.1 C.10 D.1100 E.10001 F.10010 18.Given the following, 1.public class ObjComp { 2.public static void main(String [] args){ 3.int result = 0;4.ObjComp oc = new ObjComp();5.Object o = oc;6.7.if(o == oc)result = 1;8.if(o!= oc)result = result + 10;9.if(o.equals(oc))result = result + 100;10.if(oc.equals(o))result = result + 1000;11.12.System.out.println(“result = ” + result);13.} 14.} what is the result? A.1 B.10 C.101 D.1001 E.1101 19.Which two statements are true about wrapper or String classes?(Choose two.)A.If x and y refer to instances of different wrapper classes, then the fragment x.equals(y)will cause a compiler failure.B.If x and y refer to instances of different wrapper classes, then x == y can sometimes be true.C.If x and y are String references and if x.equals(y)is true, then x == y is true.D.If x, y, and z refer to instances of wrapper classes and x.equals(y)is true, and y.equals(z)is true, then z.equals(x)will always be true.E.If x and y are String references and x == y is true, then y.equals(x)will be true.
第二篇:JAVA工程師筆試題
一、選擇題
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程序員筆試題
JAVA 程序員筆試題
時間:30分鐘
試題一:
簡單描述一下什么是事務管理,事務管理中有哪些語句?
姓名:
試題二:
跳出當前循環的關鍵詞是什么?繼續本次循環的關鍵詞是什么?
試題三:
在JSP頁面源代碼中寫 “${flag}”是代表什么意思?
試題四:
請寫出最少五種設計模式的名稱。
試題五:
請寫出Eclipse 中下列功能的快捷鍵: 刪除當前行: 注釋當前行:
代碼助手完成一些代碼的插入: 打開類型: 打開資源:
試題六:
什么情況下Eclipse不編譯生成Class文件?
深圳市九城恩科軟件技術有限公司
java程序員筆試題
試題七:
public static void main(String[] args){
int i=3,j=16;do{ if(++i>=j--)continue;}while(i<9);System.out.println(“i=”+i+“;j=”+j);} 這段程序運行后輸出的結果是什么?
試題八:
public class One {
} public class Two extends One {
} protected void printA(){System.out.println(“two A”);} private void printB(){System.out.println(“two B”);} public static void main(String[] args){ Two t = new Two();t.printAB();} protected void printA(){System.out.println(“one A”);} private void printB(){System.out.println(“one B”);} protected void printAB(){printA();printB();} 這段程序運行后輸出的結果是什么?
試題九:
有一個表 “表A” 中包含 “姓名”,“成績”兩個字段,請寫一個SQL語句查詢出“成績”大于60分的,“姓名”有重復的人的名字
試題十:
請寫一個方法實現:傳入的一個大于10位的字符串,把字符串的最后兩位移動到字符串的第4位后面。
第四篇:Java程序員筆試題
Java程序員筆試題
說明:該份題目要求在1小時內答完
1、工廠方法模式和抽象工廠模式的區別
2、jsp/servlet 中 forward, include, reDirect 之間的區別
3、JSP中的兩種include包含指令的區別與用法
4、ArrayList和Vector的區別,HashMap和Hashtable及HashSet的區別?
5、請說明在實際應用中,java.sql 包中的Statement和PreparedStatement有何區別?
6、如何遍歷一個集合(collection),并在屏幕上打印出集合中的每個元素public void printStr
(Collection cols){
}
7、寫一個方法,實現字符串的反轉,例如:輸入abc,輸出cba
PublicString reverseStr(String str){
//代碼
}
8、輸入為整數數組,請寫出如下的排序算法,使得數組data里面存儲的數字隨數組腳標的增大而依
次增大,即越小的數字存儲的位置越靠前
Public void sort(int[]data){
}
9、用戶在JSP: input.jsp中輸入姓名和手機號碼,點”Done”按鈕來提交請求到一個/ 6
servlet:test.java。test.java將輸入的姓名和手機號碼存儲在文件store.txt里。
請寫出input.jsp, test.java的程序源碼,并在input.jsp和test.java中分別通過js和java代碼對輸入進行校驗,如果1)姓名項沒有填寫或者輸入的長度超過了20個字符2)手機號碼項沒有填寫,或者輸入了非數字的字符或者輸入的長度不是13位,則返回input.jsp,并給出相應的錯誤提示。
10、有若干條有關城市的信息,每條包括如下屬性:ID(唯一遞增的序列),CITY(城市名稱),DESC(城市說明),要求設計一套數據結構及算法使得1)所有登陸系統的用戶均能使用這些城市信息2)能夠根據城市ID 號或名稱獲得城市的其他信息3)如果從該數據結構中找不到合適的城市信息,可以往該數據結構中添加新的城市信息,但相同的城市(ID號或名稱有任意一個相同均認為是同一城市)在數據結構中只能有一條記錄 4)如任一條城市信息,超過兩個小時沒有被使用(查詢)則需自動將其刪除
pubic class CityCache{
}
11、讀下面一段程序,寫出運行結果
----
pubicclassBaseClass{
static{
System.out.println(“aaaaa”);/ 6
}
BaseClass(){
System.out.println(“11111”);
}
}
publicclassDerivedClass
extendsBaseClass{
static{
System.out.println(“bbbbb”);
}
DerivedClass(){
System.out.println(“22222”);
}
}
publicclassStartRun {
public static void main(String[ ] args){
DerivedClasssdc 1 = newDerivedClass();
dc1 = newDerivedClass();
}
}
12、請寫出符合要求的sql 語句(假定數據庫為Oracle)。/ 6
現有數據表a,建表語句如下:
create table a(bm char(4),——編碼
mc varchar2(20)——名稱)
表中數據如下
bmmc
11111111
11121111
11131111
11141111
要求1:用一條sql語句實現對表a中數據的復制,即達到如下的結果(2)bmmc
11111111
11121111
11131111
11141111
11111111
11121111
11131111
11141111/ 6
要求2:請刪除表中重復的記錄(bm和mc都相同的記錄為重復記錄)
13、classStack {
LinkedListlist = new LinkedList()
public synchronized void push(Objectx){
synchronized(list){
list.addLast(x);
notify();
}
}
public synchronized Object pop(){
synchronized(list){
if(list.size()<=0)
wait();
return list.removeLast();
}
}/ 6
}
請問上面這個類中有什么錯誤?應該怎么解決?14、15、請寫出MSSQL、ServerMysql和ORACE實現分頁算法的sql語句。UNIX和網絡基礎,依次寫出完成下列的操作命令,最好有常用參數的簡單說明
1)如何顯示當前的IP配置信息
2)查看當前目錄
3)拷貝文件或目錄
4)移動文件或目錄
5)刪除文件或目錄
6)切換用戶
7)修改文件或目錄的權限
8)查看日志文件的最后1行
9)查看系統內存、CPU的使用狀況
10)查看系統正在運行的和apache相關的進程/ 6
第五篇:軟件開發工程師(JAVA)筆試題A
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 ‘李%’