九九热最新网址,777奇米四色米奇影院在线播放,国产精品18久久久久久久久久,中文有码视频,亚洲一区在线免费观看,国产91精品在线,婷婷丁香六月天

JAVA基礎(chǔ)面試題1

上傳人:仙*** 文檔編號(hào):28991762 上傳時(shí)間:2021-09-23 格式:DOC 頁(yè)數(shù):13 大?。?6KB
收藏 版權(quán)申訴 舉報(bào) 下載
JAVA基礎(chǔ)面試題1_第1頁(yè)
第1頁(yè) / 共13頁(yè)
JAVA基礎(chǔ)面試題1_第2頁(yè)
第2頁(yè) / 共13頁(yè)
JAVA基礎(chǔ)面試題1_第3頁(yè)
第3頁(yè) / 共13頁(yè)

下載文檔到電腦,查找使用更方便

15 積分

下載資源

還剩頁(yè)未讀,繼續(xù)閱讀

資源描述:

《JAVA基礎(chǔ)面試題1》由會(huì)員分享,可在線閱讀,更多相關(guān)《JAVA基礎(chǔ)面試題1(13頁(yè)珍藏版)》請(qǐng)?jiān)谘b配圖網(wǎng)上搜索。

1、JAVA語(yǔ)言基礎(chǔ)筆試題-1Question 1 (43)Given:1. class TestA 2. public void start() System.out.println(”TestA”); 3. 4. public class TestB extends TestA 5. public void start() System.out.println(”TestB”); 6. public static void main(String args) 7. (TestA)new TestB().start(); / TestA x=new TestB(); x.start();8. 9

2、. What is the result?A. TestAB. TestBC. Compilation fails.D. An exception is thrown at runtime.答案:B考點(diǎn):繼承環(huán)境下,父類引用變量指向子類的問題。說明:繼承環(huán)境下,父類引用變量指向子類對(duì)象時(shí)調(diào)用的方法應(yīng)從子類先找,如果子類沒有找到再?gòu)母割愔胁檎?。Question 2Given:1. interface TestA String toString(); 2. public class Test 3. public static void main(String args) 4. System.out

3、.println(new TestA() 5. public String toString() return “test”; 6. );7. 8. What is the result?A. testB. nullC. An exception is thrown at runtime.D. Compilation fails because of an error in line 1.E. Compilation fails because of an error in line 4.F. Compilation fails because of an error in line 5.答案

4、:A考點(diǎn):接口的考察。說明:本體在輸出語(yǔ)句中直接創(chuàng)建TestA的對(duì)象,并在語(yǔ)句中完成并且調(diào)用toString()方法。Question 3Given:11. public abstract class Shape 12. int x;13. int y;14. public abstract void draw();15. public void setAnchor(int x, int y) 16. this.x = x;17. this.y = y;18. 19. and a class Circle that extends and fully implements the Shape

5、class.Which is correct?A. Shape s = new Shape();s.setAnchor(10,10);s.draw();B. Circle c = new Shape();c.setAnchor(10,10);c.draw();C. Shape s = new Circle();s.setAnchor(10,10);s.draw();D. Shape s = new Circle();s-setAnchor(10,10);s-draw();E. Circle c = new Circle();c.Shape.setAnchor(10,10);c.Shape.dr

6、aw();答案:B考點(diǎn):考察子類繼承和抽象類的問題。說明:在繼承和抽象類中,子類對(duì)象不能調(diào)用父類的方法,當(dāng)父類引用變量指向之類對(duì)行時(shí),指代的是父類的部分,不能調(diào)用子類的方法。抽象類中未完成的放法不能被調(diào)用,只有完成了方法才能被調(diào)用。Question 4Given:10. abstract public class Employee 11. protected abstract double getSalesAmount();12. public double getCommision() 13. return getSalesAmount() * 0.15;14. 15. 16. class

7、Sales extends Employee 17. / insert method here18. Which two methods, inserted independently at line 17, correctlycomplete the Sales class? (Choose two.)A. double getSalesAmount() return 1230.45; B. public double getSalesAmount() return 1230.45; C. private double getSalesAmount() return 1230.45; D.

8、protected double getSalesAmount() return 1230.45; 答案:AB考點(diǎn):抽象類被繼承時(shí),方法的可見度問題。說明:當(dāng)抽象類被繼承時(shí),子類必須重寫父類的抽象方法,且子類的方法可見度必須比父類的可見度更廣。Question 5Given:10. interface Data public void load(); 11. abstract class Info public abstract void load(); Which class correctly uses the Data interface and Info class?A. public

9、 class Employee extends Info implements Data public void load() /*do something*/ B. public class Employee implements Info extends Data public void load() /*do something*/ C. public class Employee extends Info implements Data public void load() /*do something */ public void Info.load() /*do something

10、*/ D. public class Employee implements Info extends Data public void Data.load() /*d something */ public void load() /*do something */ E. public class Employee implements Info extends Data public void load() /*do something */ public void Info.load() /*do something*/ F. public class Employee extends

11、Info implements Datapublic void Data.load() /*do something*/ public void Info.load() /*do something*/ 答案:A考點(diǎn):抽象類和接口在繼承和繼承接口中的問題。說明:子類可以同時(shí)繼承抽象類和接口類,子類的必須必須重寫抽象類和接口的方法。如果抽象類和接口有相同的未完成的方法名,這子類中只要寫一個(gè)就可以。Question 6Given:11. public abstract class Shape 12. private int x;13. private int y;14. public abstra

12、ct void draw();15. public void setAnchor(int x, int y) 16. this.x = x;17. this.y = y;18. 19. Which two classes use the Shape class correctly? (Choose two.)A. public class Circle implements Shape private int radius;B. public abstract class Circle extends Shape private int radius;C. public class Circl

13、e extends Shape private int radius;public void draw();D. public abstract class Circle implements Shape private int radius;public void draw();E. public class Circle extends Shape private int radius;public void draw() /* code here */F. public abstract class Circle implements Shape private int radius;p

14、ublic void draw() / code here */ 答案:E考點(diǎn):繼承環(huán)境下,抽象類的抽象放法被繼承時(shí)的問題.說明:抽象類被繼承時(shí)應(yīng)使用extends,且抽象類中的抽象方法應(yīng)給在子類中完成。Question 7Which two classes correctly implement both the java.lang.Runnableand the java.lang.Clonable interfaces? (Choose two.)A. public class Sessionimplements Runnable, Clonable public void run();

15、public Object clone();B. public class Sessionextends Runnable, Clonable public void run() / do something */ public Object clone() / make a copy */ C. public class Sessionimplements Runnable, Clonable public void run() / do something */ public Object clone() /* make a copy */ D. public abstract class

16、 Sessionimplements Runnable, Clonable public void run() / do something */ public Object clone() /*make a copy */ E. public class Sessionimplements Runnable, implements Clonable public void run() / do something */ public Object clone() / make a copy */ 答案:CE考點(diǎn):考察接口被子類繼承的規(guī)則。說明:接口被繼承時(shí)應(yīng)在類后面寫上被繼承的接口,且要完成

17、接口中所有未完成的方法。Question 8Click the Exhibit button.1. public class GoTest 2. public static void main(String args) 3. Sente a = new Sente(); a.go();4. Goban b = new Goban(); b.go();5. Stone c = new Stone(); c.go();6. 7. 8.9. class Sente implements Go 10. public void go() System.out.println(”go in Sente.”

18、); 11. 12.13. class Goban extends Sente 14. public void go() System.out.println(”go in Goban”); 15. 16.17. class Stone extends Goban implements Go 18.19. interface Go public void go(); What is the result?A. go in Gobango in Sentego in SenteB. go in Sentego in Sentego in GobanC. go in Sentego in Goba

19、ngo in GobanD. go in Gobango in Gobango in SenteE. Compilation fails because of an error in line 17.答案:C考點(diǎn):考察接口被實(shí)現(xiàn)和的問題。說明:本題考察接口被實(shí)現(xiàn)時(shí)應(yīng)重寫接口中的方法,當(dāng)一個(gè)子類同時(shí)繼承和實(shí)現(xiàn)接口時(shí),在兩父類中都有的方法,在子類中只需繼承非接口父類的方法或重寫父類的方法。Question 9Given:11. public static void parse(String str) 12. try 13. float f= Float.parseFloat(str);14. ca

20、tch (NumberFormatException nfe) 15. f= 0;16. finally 17. System.out.println(f);18. 19. 20. public static void main(String args) 21. parse(“invalid”);22. What is the result?A. 0.0B. Compilation fails.C. A ParseException is thrown by the parse method at runtime.D. A NumberFormatException is thrown by

21、the parse method atruntime.答案:B考點(diǎn):考察異常和變量定義問題。說明:本題通過異常來考察變量定義的使用塊,在try塊中定義的f不能在catch塊中不能再使用f,否則將導(dǎo)致編譯錯(cuò)誤。Question 10Click the Exhibit button.1. public class Test 2. int x= 12;3. public void method(int x) 4. x+=x;5. System.out.println(x);6. 7. Given:34. Test t = new Test();35. t.method(5);What is the

22、output from line 5 of the Test class?A. 5B. 10C. 12D. 17E. 24答案:C考點(diǎn):考察形參與實(shí)參的用法。說明:本題method()方法被調(diào)用且把5賦值給形參后,在方法中只改變形參的值,不管形參如何改變,都不影響實(shí)參的值。Question 11Given:55. int x= 1, 2,3,4, 5; / new int1,2,3,4,556. int y =x;57. System.out.println(y2);Which is true?A. Line 57 will print the value 2.B. Line 57 will

23、print the value 3.C. Compilation will fail because of an error in line 55.D. Compilation will fail because of an error in line 56.答案:B考點(diǎn):考察數(shù)組的用法。說明:本題數(shù)組x把值賦給數(shù)組y,再通過數(shù)組下標(biāo)來找數(shù)值。Question 12Given:35. String #name = “Jane Doe”;36. int $age=24;37. Double _height = 123.5;38. double temp = 37.5;Which two are

24、true? (Choose two.)A. Line 35 will not compile.B. Line 36 will not compile.C. Line 37 will not compile.D. Line 38 will not compile.答案:BC考點(diǎn):標(biāo)示符的用法。說明:標(biāo)識(shí)符由大小寫字母,下劃線,數(shù)字,$符號(hào)組成,開頭可以是大小寫字母,下劃線,和$符號(hào)。Question13Which two code fragments correctly create and initialize a static arrayof int elements? (Choose tw

25、o.)A. static final int a = 100,200 ;B. static final int a;static a=new int2; a0=100; a1=200; C. static final int a = new int2 100,200 ;D. static final int a;static void init() a = new int3; a0=100; a1=200; 答案:AC考點(diǎn):考察數(shù)組的定義。說明:一個(gè)數(shù)組可以直接初始化,系統(tǒng)會(huì)制動(dòng)幫你創(chuàng)建,也可以創(chuàng)建后在初始化。Question 14Given:11. public static void ma

26、in(String args) 12. Object obj =new int 1,2,3 ;13. int someArray = (int)obj;14. for (int i: someArray) System.out.print(i +“ “)15. What is the result?A. 1 2 3B. Compilation fails because of an error in line 12.C. Compilation fails because of an error in line 13.D. Compilation fails because of an err

27、or in line 14.E. A ClassCastException is thrown at runtime.答案:A考點(diǎn):考察數(shù)組的用法。說明:本題創(chuàng)建一個(gè)數(shù)組賦給它的引用變量為obj,在通過obj把數(shù)組的地址賦給array。Question 15Given:10. class Foo 11. static void alpha() /* more code here */ 12. void beta() /* more code here */ 13. Which two are true? (Choose two.)A. Foo.beta() is a valid invocat

28、ion of beta().B. Foo.alpha() is a valid invocation of alpha().C. Method beta() can directly call method alpha().D. Method alpha() can directly call method beta().答案:Question 16A programmer needs to create a logging method that can accept anarbitrary number of arguments. For example, it may be called

29、 in theseways:logIt(”log message 1 “);logIt(”log message2”,”log message3”);logIt(”log message4”, “l(fā)og message5”, “l(fā)og message6“);Which declaration satisfies this requirement?A. public void logIt(String * msgs)B. public void logIt(String msgs)C. public void logIt(String. msgs)D. public void logIt(Str

30、ing msg1, String msg2, String msg3)Question 17A programmer is designing a class to encapsulate the informationabout an inventory item. A JavaBeans component is needed todo this. The Inventoryltem class has private instance variables to storethe item information:10. private int itemId;11. private Str

31、ing name;12. private String description;Which method signature follows the JavaBeans naming standards formodifying the itemld instance variable?A. itemID(int itemId)B. update(int itemId)C. setItemId(int itemId)D. mutateItemId(int itemId)E. updateItemID(int itemId)Question 18Click the Exhibit button.

32、1. public class A 2.3. private int counter = 0;4.5. public static int getInstanceCount() 6. return counter;7. 8.9. public A() 10. counter+;11. 12.13. Given this code from Class B:25. A a1 =new A();26. A a2 =new A();27. A a3 =new A();28. System.out.printIn(A.getInstanceCount() );What is the result?A.

33、 Compilation of class A fails.B. Line 28 prints the value 3 to System.out.C. Line 28 prints the value 1 to System.out.D. A runtime error occurs when line 25 executes.E. Compilation fails because of an error on line 28.Question 19A JavaBeans component has the following field:11. private boolean enabl

34、ed;Which two pairs of method declarations follow the JavaBeans standardfor accessing this field? (Choose two.)A. public void setEnabled( boolean enabled)public boolean getEnabled()B. public void setEnabled( boolean enabled)public void isEnabled()C. public void setEnabled( boolean enabled)public bool

35、ean isEnabled()D. public boolean setEnabled( boolean enabled)public boolean getEnabled()Question 2041. Given:10. class One 11. public One foo() return this; 12. 13. class Two extends One 14. public One foo() return this; 15. 16. class Three extends Two 17. / insert method here18. Which two methods,

36、inserted individually, correctly complete the Threeclass? (Choose two.)A. public void foo() B. public int foo() return 3; C. public Two foo() return this; D. public One foo() return this; E. public Object foo() return this; Question 21Given:10. class One 11. void foo() 12. 13. class Two extends One

37、14. /insert method here15. Which three methods, inserted individually at line 14, will correctlycomplete class Two? (Choose three.)A. int foo() /* more code here */ B. void foo() /* more code here */ C. public void foo() /* more code here */ D. private void foo() /* more code here */ E. protected vo

38、id foo() /* more code here */ Question 22Click the Exhibit button.1. public interface A 2. public void doSomething(String thing);3. 1. public class AImpl implements A 2. public void doSomething(String msg) 3. 1. public class B 2. public A doit() 3. / more code here4. 5.6. public String execute() 7.

39、/ more code here8. 9. 1. public class C extends B 2. public AImpl doit() 3. / more code here4. 5.6. public Object execute() 7. / more code here8. 9. Which statement is true about the classes and interfaces in theexhibit?A. Compilation will succeed for all classes and interfaces.B. Compilation of class C will fail because of an error in line 2.C. Compilation of class C will fail because of an error in line 6.D. Compilation of class AImpl will fail because of an error in line 2.

展開閱讀全文
溫馨提示:
1: 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
2: 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
3.本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
5. 裝配圖網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

相關(guān)資源

更多
正為您匹配相似的精品文檔

相關(guān)搜索

關(guān)于我們 - 網(wǎng)站聲明 - 網(wǎng)站地圖 - 資源地圖 - 友情鏈接 - 網(wǎng)站客服 - 聯(lián)系我們

copyright@ 2023-2025  zhuangpeitu.com 裝配圖網(wǎng)版權(quán)所有   聯(lián)系電話:18123376007

備案號(hào):ICP2024067431號(hào)-1 川公網(wǎng)安備51140202000466號(hào)


本站為文檔C2C交易模式,即用戶上傳的文檔直接被用戶下載,本站只是中間服務(wù)平臺(tái),本站所有文檔下載所得的收益歸上傳人(含作者)所有。裝配圖網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)上載內(nèi)容本身不做任何修改或編輯。若文檔所含內(nèi)容侵犯了您的版權(quán)或隱私,請(qǐng)立即通知裝配圖網(wǎng),我們立即給予刪除!