Java刷題日記 2018-08-01

來源:互聯網
上載者:User

標籤:lsm   read   介面隔離   類型   float   eva   equals   實值型別   pre   

 

No.1

 1 public class EqualsMethod 2 { 3     public static void main(String[] args) 4     { 5         Integer n1 = new Integer(47); 6         Integer n2 = new Integer(47); 7         System.out.print(n1 == n2); 8         System.out.print(","); 9         System.out.println(n1 != n2);10     }11 }

輸出結果:

false,true
註:使用Integer a = 1;或Integer a = Integer.valueOf(1); 在值介於-128至127直接時,作為基本類型。使用Integer a = new Integer(1); 時,無論值是多少,都作為對象。No.2
1 class  Parent{2         public  float  aFun(float a, float b) { }3 } 4 class  Child  extends  Parent{5
6 }

將以下哪種方法插入行5是不合法的。(    )

A.  float aFun(float  a,  float  b){ }B.  public int aFun(int a, int b) { }C.  public float aFun(float  p,  float q){ }D.  private int aFun(int a,  int  b){ }

 

答案:A
註:方法重寫應遵循“三同一小一大”原則:“三同”:即方法名相同,形參列表相同,傳回值類型相同;“一小”:子類方法聲明拋出的異常比父類方法聲明拋出的異常更小或者相等;“一大”:子類方法的存取修飾詞應比父類方法更大或相等。

  

No.3

對於線程局部儲存TLS(thread local storage),以下表述正確的是:

 
答案:ABD
註:

物件導向的五大基本原則單一職責原則(SRP)
開放封閉原則(OCP) 
裡氏替換原則(LSP) 
依賴倒置原則(DIP) 
介面隔離原則(ISP)

 

Java刷題日記 2018-08-01

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.