




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、question no: 11、public class test public static void changestr(string str)str="welcome"public static void main(string args) string str="1234"changestr(str);system.out.println(str);please write the output result :question no:21. public class test 2. static boolean foo(char c) 3. s
2、ystem.out.print(c);4. return true;5. 6. public static void main( string argv ) 7. int i =0;8. for ( foo('a'); foo('b')&&(i<2); foo('c')9. i+ ;10. foo('d');12. 13. 14. what is the result?a. abdcbdcbb. abcdabcdc. compilation fails.d. an exception is thrown at
3、 runtime.question no: 31. class a 2. protected int method1(int a, int b) return 0; 3. which two are valid in a class that extends class a? (choose two)a. public int method1(int a, int b) return 0; b. private int method1(int a, int b) return 0; c. private int method1(int a, long b) return 0; d. publi
4、c short method1(int a, int b) return 0; e. static protected int method1(int a, int b) return 0; question no: 41. public class outer2. public void someoutermethod() 3. / line 34. 5. public class inner6. public static void main( stringargv ) 7. outer o = new outer();8. / line 89. 10. which instantiate
5、s an instance of inner?a. new inner(); / at line 3b. new inner(); / at line 8c. new o.inner(); / at line 8d. new outer.inner(); / at line 8/new outer().new inner()question no: 5which method is used by a servlet to place its session id in a url that is written to the servlets response output stream?a
6、. the encodeurl method of the httpservletrequest interface.b. the encodeurl method of the httpservletresponse interface.c. the rewriteurl method of the httpservletrequest interface.d. the rewriteurl method of the httpservletresponse interface.question no: 6which two are equivalent? (choose two)a. &l
7、t;%= yoshibean.size%>b. <%= yoshibean.getsize()%>c. <%= yoshibean.getproperty("size")%>d. <jsp:getproperty id="yoshibean" param="size"/>e. <jsp:getproperty name="yoshibean" param="size"/>f. <jsp:getproperty id="yosh
8、ibean" property="size"/>g. <jsp:getproperty name="yoshibean" property="size"/>question no: 7which of the following statements regarding the lifecycle of a session bean are correct? 1. java.lang.illegalstateexception is thrown if sessioncontext.getejbobject
9、() is invoked when a stateful session bean instance is passivated. 2. sessioncontext.getrollbackonly() does not throw an exception when a session bean with bean-managed transaction demarcation is activated. 3. an exception is not thrown when sessioncontext.getusertransaction() is called in the after
10、begin method of a bean with container-managed transactions. 4. jndi access to java:comp/env is permitted in all the sessionsynchronization methods of a stateful session bean with container-managed transaction demarcation. 5. accessing resource managers in the sessionsynchronization.afterbegin method
11、 of a stateful session bean with bean-managed transaction does not throw an exception.第二部分:概念題1 描述struts體系結構?對應各個部分的開發(fā)工作主要包括哪些?2 xml包括哪些解釋技術,區(qū)別是什么?3 jsp有哪些內置對象和動作?它們的作用分別是什么?4、sql問答題select * from table和select * from table where name like '%' and addr like '%' and (1_addr like '%&
12、#39; or 2_addr like '%' or 3_addr like '%' or 4_addr like '%' ) 的檢索結果為何不同?5、sql問答題表結構:1、 表名:g_cardapply字段(字段名/類型/長度):g_applyno varchar 8;/申請單號(關鍵字)g_applydate bigint 8;/申請日期g_state varchar 2;/申請狀態(tài)2、 表名:g_cardapplydetail字段(字段名/類型/長度):g_applyno varchar 8;/申請單號(關鍵字)g_name varcha
13、r 30;/申請人姓名g_idcard varchar 18;/申請人身份證號g_state varchar 2;/申請狀態(tài)其中,兩個表的關聯(lián)字段為申請單號。題目:1、 查詢身份證號碼為440401430103082的申請日期2、 查詢同一個身份證號碼有兩條以上記錄的身份證號碼及記錄個數(shù)3、 將身份證號碼為440401430103082的記錄在兩個表中的申請狀態(tài)均改為074、 刪除g_cardapplydetail表中所有姓李的記錄public class test public static void changestr(string str)str="welcome"p
14、ublic static void main(string args) string str="1234"changestr(str);system.out.println(str);這一題我想他主要考查 static這個關鍵字,changestr是個靜態(tài)的方法(類方法)那么str應該也是一個靜態(tài)成員,所有的對象都是公用這樣的一個成員,那么對他的修改應該是可以保持的。而為什么最后的結果卻是初始值1234,我有點迷惑終于明白了:按值傳遞意味著當將一個參數(shù)傳遞給一個函數(shù)時,函數(shù)接收的是原始值的一個副本。因此,如果函數(shù)修改了該參數(shù),僅改變副本,而原始值保持不變。按引用傳遞意味著當
15、將一個參數(shù)傳遞給一個函數(shù)時,函數(shù)接收的是原始值的內存地址,而不是值的副本。因此,如果函數(shù)修改了該參數(shù),調用代碼中的原始值也隨之改變。不管是在c/c+中還是在java函數(shù)調用都是傳值調用,.當參數(shù)是對象的時候,傳遞的是對象的引用,這個和c/c+傳遞指針是一個道理,在函數(shù)中改變引用本身,不會改變引用所指向的對象,而在question no: 1中只是改變了引用,所以在main函數(shù)中輸出還是原來的那個值:1234參數(shù)是對象時傳的是地址。但str="welcome"相當于str=new string("welcome");,所以原對象沒變??梢詤⒖家韵麓a:pu
16、blic class test public int ss = 999;public test(int s)ss = s;public static void changestr(test t)t.ss = 888;public static void main(string args) test t = new test(999);changestr(t);system.out.println(t.ss);public class test public int ss = 999;public test(int s)ss = s;public static void changestr(te
17、st t)t = new test(888);public static void main(string args) test t = new test(999);changestr(t);system.out.println(t.ss);question no:21. public class test 2. static boolean foo(char c) 3. system.out.print(c);4. return true;5. 6. public static void main( string argv ) 7. int i =0;8. for ( foo('a&
18、#39;); foo('b')&&(i<2); foo('c')9. i+ ;10. foo('d');12. 13. 14. what is the result?a. abdcbdcbb. abcdabcdc. compilation fails.d. an exception is thrown at runtime做一下這個吧!第一題終于清楚了。對象是傳引用的。但是下面還是有區(qū)別public class test6 public int ss = 999;public test6(int s)ss = s;publi
19、c static void changestr(test6 t)t.ss = 888;public static void change(test6 t)t = new test6(222);public static void main(string args) test6 t = new test6(999);changestr(t);system.out.println(t.ss);change(t);system.out.println(t.ss);import javax.swing.joptionpane;public class test public void changest
20、r(string str)str="welcome"public void main(string args) string str="1234"str="welcome"/changestr(str);joptionpane.showmessagedialog(null,str); 如果這樣做的話結果是welcome在我我想說的是在c語言以后所有的參數(shù)傳遞都是值傳遞,問題是傳的值是是什么,而沒有什么引用傳遞之類的東西。關于輸出為1234而不是welcome 還有待進一步分析。我現(xiàn)在去上課了,回來再和大家細說對第一題的詳細分析:jav
21、a中函數(shù)參數(shù)傳遞是值傳遞,在c語言以后的都是這樣的,關鍵是傳進來的值是什么(這一點我在上面說了到一次)。如果參數(shù)是基礎類型,如int型的,則傳進來的是int型變量的值,這個值放在堆里。舉個例子:void fun(int i);int i = 5;fun(i);傳進fun函數(shù)的是5;如果參數(shù)是引用類型。如string型的,則傳進來的是string型變量的值,這個值放在棧里,此值是該變量將要指向的對象的地址。舉個例子:void fun(string str0);string str = "hello"fun(str);fun()方法調用時第一件事就是,做了一個賦值操作:str0
22、 = str;這個操作的結果就是將str變量的值傳給str0變量的值,也就是使得str0也指向str所指向的對象。對str0所指向的對象做修改操作,也就是對str所指的對象做修改。有了上面的兩點,我想做第一個題目一定是沒什么問題的了:說明:為了方便分析我把changestr()方法中的參數(shù)名改成了str0。改動后的代碼如下:1.public class test public static void changestr(string str0)str0="welcome"public static void main(string args) string str=&quo
23、t;1234"changestr(str);system.out.println(str);哎,第一題沒那么復雜,都說的離譜了,具體討論請見tij的附錄一 關于別名和引用那一章.我們不爭論java到底是傳值還是傳引用,因為兩者某種意義上都是正確的.傳值的認為傳遞引用本身是傳值行為,這沒錯,可我們一般把reference當成了對象,所以說成傳引用也說得過去,概念就不多說了.為什么str在changestr之后沒變?這是因為java對所有的外覆類性(基本類型的對應類)是采用所謂的恒常對象(唯讀對象,read- only),這些外覆類中的任何函數(shù)行為的調用都不會改變原對象,而是產生一個新對
24、象,這就是為什么我們在需要動態(tài)增加string時要用 stringbuffer的原因.可對于我們自己所創(chuàng)建的對象,并沒有這個"恒常"的特性,所以在這里有個"別名"現(xiàn)象,也就是幾個引用同時指向一個對象,任何一個引用對對象的修改都將影響到其他.在這個例子中,changestr函數(shù)的行為其實產生了一個新的對象,函數(shù)內的str是局部性的,它指向新的對象,可對原對象沒有產生任何影響.不知道我的解釋清楚了,更具體討論請見thinking in java 對第一題的詳細分析:java中函數(shù)參數(shù)傳遞是值傳遞,在c語言以后的都是這樣的,關鍵是傳進來的值是什么(這一點我在上
25、面說了到一次)。如果參數(shù)是基礎類型,如int型的,則傳進來的是int型變量的值,這個值放在堆里。舉個例子:void fun(int i);int i = 5;fun(i);傳進fun函數(shù)的是5;如果參數(shù)是引用類型。如string型的,則傳進來的是string型變量的值,這個值放在棧里,此值是該變量將要指向的對象的地址。舉個例子:void fun(string str0);string str = "hello"fun(str);fun()方法調用時第一件事就是,做了一個賦值操作:str0 = str;這個操作的結果就是將str變量的值傳給str0變量的值,也就是使得str0
26、也指向str所指向的對象。對str0所指向的對象做修改操作,也就是對str所指的對象做修改。有了上面的兩點,我想做第一個題目一定是沒什么問題的了:說明:為了方便分析我把changestr()方法中的參數(shù)名改成了str0。改動后的代碼如下:1.public class test 2. public static void changestr(string str0)3. str0="welcome"4. 5. public static void main(string args) 6. string str="1234"7. changestr(str)
27、;8. system.out.println(str);9. 10.第7行代碼執(zhí)行過程如下:將str的值賦給str0,使得str0和str指向同一個string類對象1234而在changestr()方法中第3行代碼執(zhí)行的結果是將str0值(也就是對象的地址)做了修改,str0的值為string類對象welcome的地址,這樣一來,使得str和str0所指向的對象不再是同一個對象了,而且str的值并沒有改變,也就是說str還是指向string類對象1234的。綜上所述,程序最終的結果一定是1234。補充:ziyongkun 在 2006-05-10 10:08:00 發(fā)的貼子里說的不是很對,并
28、不是一個副本的問題,它們會指向同一個對象的。question no:21. public class test 2. static boolean foo(char c) 3. system.out.print(c);4. return true;5. 6. public static void main( string argv ) 7. int i =0;8. for ( foo('a'); foo('b')&&(i<2); foo('c')9. i+ ;10. foo('d');12. 13. 14.
29、=考察的是for語句的執(zhí)行過程:for(1;2;3)過程如下:1;2;3;2;.當i<2時,便不再執(zhí)行。其實是基礎細心4、sql問答題select * from table和select * from table where name like '%' and addr like '%' and (1_addr like '%' or 2_addr like '%' or 3_addr like '%' or 4_addr like '%' ) 的檢索結果為何不同?=前者檢索全部,后者有三種情
30、況檢索不出:namenull或addr=null或1_addr like 2_addr 3_addr 4_addr其一為null.4、sql問答題select * from table和select * from table where name like '%' and addr like '%' and (1_addr like '%' or 2_addr like '%' or 3_addr like '%' or 4_addr like '%' ) 的檢索結果為何不同?答:前者檢索所有記錄,
31、后者只能檢索出 name 和addr中非null的記錄。5、sql問答題表結構:1、 表名:g_cardapply字段(字段名/類型/長度):g_applyno varchar 8;/申請單號(關鍵字)g_applydate bigint 8;/申請日期g_state varchar 2;/申請狀態(tài)2、 表名:g_cardapplydetail字段(字段名/類型/長度):g_applyno varchar 8;/申請單號(關鍵字)g_name varchar 30;/申請人姓名g_idcard varchar 18;/申請人身份證號g_state varchar 2;/申請狀態(tài)其中,兩個表的關
32、聯(lián)字段為申請單號。題目:1、 查詢身份證號碼為440401430103082的申請日期select a.g_applydate from g_cardapply a inner join g_cardapplydetail b on a.g_applyno = b.g_applynowhere b.g_idcard = '440401430103082'2、 查詢同一個身份證號碼有兩條以上記錄的身份證號碼及記錄個數(shù)select g_idcard,count(*) as cnt from g_cardapplydetail group by g_idcardhaving count(*) > 13、 將身份證號碼為440401430103082的記錄在兩個表中的申請狀態(tài)均改為07update g_cardapplydetail set g_state = '07'where g_idcard = '440401430103082'update a set g_state = '07'from g_cardapply a inner join g_cardapply
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年天津市安全員知識題庫
- 重慶工程職業(yè)技術學院《朗讀與講故事指導》2023-2024學年第二學期期末試卷
- 西南民族大學《古生物學含實驗》2023-2024學年第二學期期末試卷
- 南京農業(yè)大學《教育評價與測量》2023-2024學年第二學期期末試卷
- 哈爾濱劍橋學院《廣告創(chuàng)意與策劃》2023-2024學年第二學期期末試卷
- 廣西體育高等??茖W?!峨姶艌隼碚撆c光波導技術》2023-2024學年第二學期期末試卷
- 2025屆河南省周口市西華縣三校聯(lián)考高三上學期一模歷史試卷
- 贛南師范大學《幼兒園體育游戲》2023-2024學年第二學期期末試卷
- 江蘇聯(lián)合職業(yè)技術學院《分子生物學(英文)》2023-2024學年第二學期期末試卷
- 廣州城建職業(yè)學院《銷售管理》2023-2024學年第二學期期末試卷
- 8.4+同一直線上二力的合成課件+2024-2025學年人教版物理八年級下冊
- 2024年河北省邢臺市公開招聘警務輔助人員(輔警)筆試專項訓練題試卷(2)含答案
- 家政公司服務員考試題庫單選題100道及答案解析
- 人工智能:AIGC基礎與應用 課件 實訓項目九 使用度加創(chuàng)作工具和剪映進行智能化短視頻創(chuàng)作
- 《日影的朝向及長短》課件
- 中職普通話教師教案模板
- 施工后期的場地恢復措施
- 七年級歷史下冊 第一單元 隋唐時期繁榮與開放的時代 第1課 隋朝的統(tǒng)一與滅亡說課稿1 新人教版
- 智能教育機器人AI項目策劃創(chuàng)業(yè)計劃書
- 《MATLAB編程及應用》全套教學課件
- T-CCSAS 001-2018 危險與可操作性分析(HAZOP分析)質量控制與審查導則
評論
0/150
提交評論