一道有關StringBuffer的面試題

2021-08-30 01:23:49 字數 460 閱讀 3265

public class test 

public static void main(string args)

}

2:現在dosomething()方法中 除去:buff = new stringbuffer();

public class test 

public static void main(string args)

}

結果:

hellohello world

hellohello world

hellohello world

技術要點:1中雖然傳入了stringbuffer物件,雖然把main中buff引用賦給了dosomething()中的形參,但是在方法內部有重新指向另外乙個物件(記憶體)。所以原來的就不起作用了!

2中始終是乙個buff物件

金山的一道有關執行緒的筆試題

在北京時參加金山校招的一道筆試題 四個執行緒,a b c d 共享乙個變數 i,ab 為加執行緒,cd 為減執行緒,四個執行緒依次執行,順序為 abcd,輸出為 0 1 2 1 0 1 2 1 0 當時覺得這道題還可以,不一會兒就寫出來了,我的思路是 四個執行緒,ab為乙個鎖,cd為乙個鎖,兩個鎖交...

一道C語言和static有關的題

有以下程式 include fun int x,int y main 執行後的輸出結果是 a a 5,11 b 5,5 c 11,11 d 11,5 i m 1含義為 i i m 1.第一次呼叫子程式fun時,賦值得 x j 1,y m 1.而子程式裡m 0,i 2.所以 執行i m 1得 i 3 ...

嵌入式系統一道中斷有關題目

interrupt double compute area double radius answer 1 isr不能返回乙個值。如果你不懂這個,那麼你不會被僱傭的。2 isr不能傳遞引數。如果你沒有看到這一點,你被雇用的機會等於第一項。3 在許多的處理器 編譯器中,浮點一般都是不可重入的。雨後些處理...