看板 java 關於我們 聯絡資訊
※ 引述《nf7series (真呆)》之銘言: : 剛在作題庫,有一題: : Given : : package test; : class target : { : public String name="hello"; : } : what can directly access and change the value of the variable name? : A.any class : B.only the Target class : C.any class in the test package : D.any class that extends Target : 結果答案是C : 我以為是A,請問答案是對的嗎?謝謝 答案沒錯 因為 class 的 access modifier 是 package 其他不同 package 的 class,連 target 這個 class 都看不到 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.114.78.239
lightening:這種題目很沒意思 這個答案的話 應該是指directly 11/17 21:27
lightening:我看錯了 XD 11/17 21:29
louisyu:沒有設定modifier,會預設為default,跟public是不同的 11/17 21:45
nf7series:thanks... 11/18 17:49
Elohim123:If a class has ‘no modifer’, then it CAN ONLY be a 02/09 16:51
Elohim123:access from the same package 02/09 16:52