澶辨晥閾炬帴澶勭悊 |
鏈€鏂頒紒涓氱瑪璇曢潰璇曢澶у叏 PDF 涓嬭澆
鏈珯鏁寸悊涓嬭澆錛?/strong>
閾炬帴錛?a target="_blank">https://pan.baidu.com/s/1BOmsv4tSMa14Cinycp92eQ
鎻愬彇鐮侊細(xì)r6w5
鐩稿叧鎴浘錛?/strong>
![]()
涓昏鍐呭錛?/strong>
1.1 閫夋嫨棰?/div>
1.1.1java 鍩虹
1. 涓嬮潰涓摢涓や釜鍙互鍦?A 鐨勫瓙綾諱腑浣跨敤錛氾紙 錛?/div>
class A {
protected int method1 (int a, int b) {
return 0;
} }
A. public int method 1 (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. public short method1 (int a, int b) { return 0; }
瑙g瓟錛欰C
涓昏鑰冩煡瀛愮被閲嶅啓鐖剁被鐨勬柟娉曠殑鍘熷垯; B錛屽瓙綾婚噸鍐欑埗綾葷殑鏂規(guī)硶錛岃闂潈闄愪笉鑳介檷浣庯紱
C錛屽睘浜庨噸杞斤紱D錛屽瓙綾婚噸鍐欑埗綾葷殑鏂規(guī)硶 榪斿洖鍊肩被鍨嬭鐩稿悓鎴栨槸鐖剁被鏂規(guī)硶榪斿洖鍊肩被鍨嬬殑瀛愮被銆?/div>
2. Abstract method cannot be static. True or False ?
A. True
B. False
瑙g瓟錛欰
鎶借薄鏂規(guī)硶鍙互鍦ㄥ瓙綾諱腑琚噸鍐欙紝浣嗘槸闈欐€佹柟娉曚笉鑳藉湪瀛愮被涓閲嶅啓錛岄潤鎬佹柟娉曞拰闈欐€佸睘
鎬т笌瀵硅薄鏄?鏃犲叧鐨勶紝鍙笌綾繪湁鍏籌紝榪欎笌 abstract 鏄煕鐩劇殑錛屾墍浠?abstract 鏄笉鑳借淇グ
涓?static錛屽惁鍒欏氨 澶卞幓浜?abstract 鐨勬剰涔変簡
3.What will be the output when you compile and execute the following program.
class Base
{
void test() {
System.out.println("Base.test()");
} }
public class Child extends Base {
void test() { System.out.println("Child.test()");}
static public void main(String[] a) {
Child anObj = new Child();
Base baseObj = (Base)anObj;
baseObj.test();
} }
Select most appropriate answer.
A. Child.test() Base.test()
B. Base.test() Child.test()
C. Base.test()
D. Child.test()
瑙g瓟錛欴
嫻嬭瘯浠g爜鐩稿綋浜庯細(xì)Base baseObj = new Child();鐖剁被鐨勫紩鐢ㄦ寚鍚戝瓙綾葷殑瀹炰緥錛屽瓙綾誨張閲嶅啓
浜嗙埗綾?鐨?test 鏂規(guī)硶錛屽洜姝よ皟鐢ㄥ瓙綾葷殑 test 鏂規(guī)硶銆?/div>
4.What will be the output when you compile and execute the following program.
class Base{
static void test() { System.out.println("Base.test()");
}}
public class Child extends Base {
void test() { System.out.println("Child.test()"); Base.test(); //Call the parent method
}
static public void main(String[] a) {
new Child().test();
}}
Select most appropriate answer.
A. Child.test() Base.test()
B. Child.test() Child.test()
5 / 237
6 / 237
C. Compilation error. Cannot override a static method by an instance method
D. Runtime error. Cannot override a static method by an instance method
瑙g瓟錛欳
闈欐€佹柟娉曚笉鑳藉湪瀛愮被涓閲嶅啓銆?/div>
5.What will be the output when you compile and execute the following program.
public class Base{
private void test() {
System.out.println(6 + 6 + "(Result)");
}
static public void main(String[] a) {
new Base().test();
}}
Select most appropriate answer.
A. 66(Result)
B. 12(Result)
C. Runtime Error.Incompatible type for +. Can't convert an int to a string.
D. Compilation Error.Incompatible type for +. Can't add a string to an int.
瑙g瓟錛欱
瀛楃涓蹭笌鍩烘湰鏁版嵁綾誨瀷閾炬帴鐨勯棶棰?濡傛灉絎竴涓槸瀛楃涓查偅涔堝悗緇氨閮芥寜瀛楃涓插鐞嗭紝
姣斿涓婅竟渚嬪瓙瑕?鏄?System.out.println("(Result)"+6 + 6 );閭d箞緇撴灉灝辨槸(Result)66錛屽鏋滅涓€
涓拰絎簩涓€傘€傘€?絎?n 涓兘鏄熀鏈暟鎹 n+1 鏄瓧絎︿覆綾誨瀷錛岄偅涔堝墠 n 涓兘鎸夊姞娉曡綆?/div>
鍑虹粨鏋滃湪涓庡瓧絎︿覆榪炴帴
6..What will be the output when you compile and execute the following program. The symbol ’? ’
means space.
1:public class Base{
2:
3: private void test() {
4:
5: String aStr = "? One? ";
6: String bStr = aStr;
7: aStr.toUpperCase();
8: aStr.trim();
9: System.out.println("[" + aStr + "," + bStr + "]");
7 / 237
10: }
11:
12: static public void main(String[] a) {
13: new Base().test();
14: } 15: }
Select most appropriate answer.
A. [ONE,? One? ]
B. [? One? ,One]
C. [ONE,One] D [ONE,ONE]
E. [? One? ,? One? ]
瑙g瓟錛欵
閫氳繃 String bStr = aStr;榪欏彞浠g爜浣?bStr 鍜?aStr 鎸囧悜鍚屼竴涓湴鍧€絀洪棿錛屾墍浠ユ渶鍚?aStr
鍜?bStr 鐨勭粨 鏋滃簲璇ユ槸涓€鏍鳳紝String 綾繪槸瀹氶暱瀛楃涓詫紝璋冪敤涓€涓瓧絎︿覆鐨勬柟娉曚互鍚庝細(xì)褰㈡垚涓€
涓柊鐨勫瓧絎︿覆銆?/div>
7.涓嬮潰鍏充簬鍙橀噺鍙?qiáng)鍏惰寖鍥寸殑闄垬q板摢浜涙槸涓嶆紜殑錛?錛夛細(xì)
|