OCJP(310-065)

单选题Given: 1.package test; 2. 3.class Target { 4.public String name = "hello";5.} What can directly access and change the value of the variable name?()A any classB only the Target classC any class in the test packageD any class that extends Target

题目
单选题
Given: 1.package test; 2. 3.class Target { 4.public String name = "hello";5.} 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
解析: 暂无解析
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

Given:Which statement is true about the class of an object that can reference the variable base? ()

A.It can be any class.

B.No class has access to base.

C.The class must belong to the geometry package.

D.The class must be a subclass of the class Hypotenuse.


参考答案:C

第2题:

下面哪个选项正确示例了传递一个参数给applet? ( )

A.<applet code=Test.class age=33 width=100 heigh=100>

B.<param name=age value=33>

C.<applet code=Test.class name-age value=33 width=100 height=100>

D.<applet Test 33>


正确答案:B
解析:该题考查对APPLET>标记中的属性PARAM的理解。属性PARAM是用来传递参数给applet的,它又有两个属性name和value,前者表示参数的名字,后者表示参数的值。选项A和C显然不对,而选项D忽略了关键字param 选项B的表示是正确的。故本题答案是B。

第3题:

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

第4题:

Class TestException  1. public class TestException extends Exception {  2. } Class a:  1. public class a {  2.  3. public String sayHello(String name) throws TestException {  4.  5. if(name == null) {  6. throw new TestException();  7. }  8.  9. return “Hello “+ name;  10. }  11.  12. }  A programmer wants to use this code in an application: 45. A a=new A();  46. System.out.println(a.sayHello(”John”));  Which two are true?()

  • A、 Class a will not compile.
  • B、 Line 46 can throw the unchecked exception TestException.
  • C、 Line 45 can throw the unchecked exception TestException.
  • D、 Line 46 will compile if the enclosing method throws a TestException.
  • E、 Line 46 will compile if enclosed in a try block, where TestException is caught.

正确答案:D,E

第5题:

以target.test.com所在网络上的所有个IP地址为目标,通过秘密SYN扫描方式,探测所有活动主机的命令为()。

A.nmap -ss -o target.test.com/24

B.nmap -sU -O target.test.com/24

C.nmap -sS -O target.test.com/24

D.nmap -iR -O target.test.com/24


参考答案:C

第6题:

下面______正确示范了传递—个参数给applet。

A.<applet code=Test.class age=33 width=100 height=100>

B.<param name=age value

C.<applet Test 33>

D.<aoolet code=Test.class name=age value=33 width=100 height=100>


正确答案:B

第7题:

使下列程序正常运行并且输出“Hello!”,横线处应填写的内容是( )。 class Test { public static void main(string[]args){ Test t=new Test; start; } Public void run{ System.out.println("Hello!¨); )

A.extends Thread

B.extends Float

C.extends Iostream

D.extends Stdio


正确答案:A
A。【解析】从后面重写了run方法来看,这是通过继承Thread类,并重写run方法定义线程体,然后创建该子类的对象的方式来创建线程。

第8题:

Given: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

第9题:

1. public class Target {  2. private int i = 0;  3. public int addOne() {  4. return ++i;  5. }  6. }  And:  1. public class Client {  2. public static void main(String[] args) {  3. System.out.println(new Target().addOne());  4. }  5. }  Which change can you make to Target without affecting Client?() 

  • A、 Line 4 of class Target can be changed to return i++;
  • B、 Line 2 of class Target can be changed to private int i = 1;
  • C、 Line 3 of class Target can be changed to private int addOne() {
  • D、 Line 2 of class Target can be changed to private Integer i = 0;

正确答案:D

第10题:

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

更多相关问题