Re: [J2SE] scjp考題

看板java作者 (小安)時間16年前 (2007/11/17 14:25), 編輯推噓3(303)
留言6則, 4人參與, 最新討論串1/1
※ 引述《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

11/17 21:27, , 1F
這種題目很沒意思 這個答案的話 應該是指directly
11/17 21:27, 1F

11/17 21:29, , 2F
我看錯了 XD
11/17 21:29, 2F

11/17 21:45, , 3F
沒有設定modifier,會預設為default,跟public是不同的
11/17 21:45, 3F

11/18 17:49, , 4F
thanks...
11/18 17:49, 4F

02/09 16:51, , 5F
If a class has ‘no modifer’, then it CAN ONLY be a
02/09 16:51, 5F

02/09 16:52, , 6F
access from the same package
02/09 16:52, 6F
文章代碼(AID): #17FebVFY (java)