Given: 1.package test; 2. 3.class Target { 4.public String n

题目
单选题
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

参考答案和解析
正确答案: A
解析: 暂无解析
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

publicclassTest{publicstaticvoidmain(String[]args){booleanassert=true;if(assert){System.out.println(”assertistrue”);}}}Given:javac-source1.3Test.javaWhatistheresult?()

A.Compilationfails.

B.Compilationsucceedswitherrors.

C.Compilationsucceedswithwarnings.

D.Compilationsucceedswithoutwarningsorerrors.


参考答案:C

第2题:

Given:Which regular expression, inserted at line 12, correctly splits test into "Test A", "Test B", and "Test C"?()

A.String regex="";

B.String regex=" .";

C.String regex=".*";

D.String regex="\\s";

E.String regex="\\.\\s*";

F.String regex="\\w[\.]+";


参考答案:E

第3题:

已知如下类说明: public class Test { private float f = 1.0f; int m = 12; static int n=1; public static void main(String arg[]) { Test t = new Test(); // 程序代码… } } 如下哪个使用是正确的?()

A.t.f

B.this.n

C.Test.m

D.Test.n


正确答案:AD

第4题:

Given:   11. String test = "This is a test";   12. String[] tokens = test.split("/s");   13. System.out.println(tokens.length);   What is the result?()

  • A、 An exception is thrown at runtime.
  • B、 1
  • C、 4
  • D、 Compilation fails.
  • E、 0

正确答案:D

第5题:

已知有下列类的说明,则下列哪个语句是正确的? ( ) public class Test { private float f=1.0f; int m=2; static int n=1; public static void main(String arg[]) { Test t=new Test(); } }

A.t.f;

B.this,n;

C.Test.m;

D.Test.f;


正确答案:A

第6题:

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

第7题:

下列程序的输出结果是class Test{public static void main(String args[]){int n=7;n<<=3;n=n&am

下列程序的输出结果是 class Test{ public static void main(String args[]){ int n=7; n<<=3; n=n&n+1|n+2^n+3; n>>=2; System.out.println(n); } }

A.0

B.-1

C.14

D.64


正确答案:C
解析:本题考查Java中的运算符。首先要清楚程序里面涉及的运算符的含义。“”是按位左移运算符,“&”是按位与运算符,“|”是按位或运算符,“^”是按位异或运算符。题目中整型变量n=7相当于二进制中的111,n=3语句执行后,n值为111000,相当于十进制的56,而语句n=n&n+1|n+2^n+3执行后,n值为57;n>>=2语句执行后,n的值为14,所以选项C正确。

第8题:

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

第9题:

执行以下代码会输出什么结果?()   public class Test {    StringgetStr(String s){  return s + “hello”;  }  public static void main(String arg[]) {           Test t= new Test();  System.out.println(t.getStr(“LiLei/n”));     } } 

  • A、 编译报错
  • B、 LiLei    hello
  • C、 LiLeihello
  • D、 无任何输出

正确答案:B

第10题:

Given: 11.String test = "a1b2c3"; 12.String[] tokens = test.split("//d"); 13.for(String s: tokens) System.out.print(s + " "); What is the result?()

  • A、a b c
  • B、1 2 3
  • C、a1b2c3
  • D、a1 b2 c3

正确答案:A

更多相关问题