当前位置:SCJP程序员认证考试题库

问题:

[单选] A class design requires that a member variable cannot be accessible directly outside the class. Which modifier should be used to obtain the access control?()    

A .  public
B .  no modifier
C .  protected
D .  private

空气压缩机漏气() 单向阀有缺陷。 安全阀未开启。 安全阀漏气。 管道或软管连接松动。 robots.txt支持的代码为()。 Allow。 Disallow。 sitemap。 nofollow。 三极管共发射极放大电路中,为保证三极管放大状态,发射结反偏,集电结正偏。 已知某种商品的需求函数为D=350-3P,供给函数为S=-250+5P。求该商品的均衡价格和均衡数量。 下列属于管理方格理论中具有代表性的领导方式的有()。 中间型领导方式。 俱乐部型领导方式。 贫乏型领导方式。 战斗集体型管理。 任务型领导方式。 A class design requires that a member variable cannot be accessible directly outside the class. Which modifier should be used to obtain the access control?()    
参考答案:

  参考解析

这个在前面也有叙述,java有四种访问类型,分别为:public,protected,default,private,其中public变量可以被所有的外部类访问,而pretected的可以被同一个包及该类的子类访问,default即没有任何修饰符的变量可以被同一个包中的类访问,而private变量只能在被该类内部被访问。题目中的外部类应该理解为除该类自身的所有其它类,因此只有使用private可以达到要求 

在线 客服