※ 引述《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
11/17 21:27, 1F
→
11/17 21:29, , 2F
11/17 21:29, 2F
推
11/17 21:45, , 3F
11/17 21:45, 3F
→
11/18 17:49, , 4F
11/18 17:49, 4F
推
02/09 16:51, , 5F
02/09 16:51, 5F
→
02/09 16:52, , 6F
02/09 16:52, 6F