若有定义String tom=""boy"";String hill=""boy"";则表达式(tom==hill)的值

题目
单选题
若有定义String tom=""boy"";String hill=""boy"";则表达式(tom==hill)的值为()
A

True

B

False

C

1

D

0

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

本题中定义了一个带有参数的构造方法javal,并定义了一个该类的对象temp。构造方法javal有两个参数:字符串name和整型age。定义对象temp时将字符串“Tom"和整数17传递给构造方法,构造方法将这两个参数打印输出。 public class javal{ String name; int age; public static void main(String[]args){ String name="Tom"; int age=17; javal temp = ; } public javal(String name, ){ ; this.age= age; System.out.println(name+"is"+age+" years old."); } }


正确答案:
第1处:new javal(name,age)
第2处:int age
第3处:this.name=name
【解析】第1处用javal的构造函数新建了一个javal的对象temp,并且带有两个参数name和age;第2处是构造函数的另一个参数;第3处将字符串“Tom”传递给构造方法 javal(String name,int age)实现对数据成员的赋值。

第2题:

Tom is a_________ (health) boy.


正确答案:
38. healthy

第3题:

Tom is a 12’yearold boy. His father sells meat and has a big shop in the city center.The shop is quite (11) and there are many customers every day, Tom usually helps his father in the shop on weekends. He does .(12) work, for example, cleaning the floor and (13) meat onto the shelf(架子).One Saturday afternoon when there (14) any meat left on the shelf.Tom's father (15) him to carry some more from another room. Tom ran to the room quickly and(16) the meat was on a high shelf. He couldn't reach it, because he was too (17 ). 'What could he do? Tom thought (18) a moment and then he had a good idea. He took two boxes and put one on the top of (19) . Then he (20) 0n them.At last, he got the meat down!

( )11.

A.well

B.busy

C.quiet


正确答案:B

第4题:

下列程序的执行结果是 public class Testff{ public static void main(String args[]){ String sl=new String("I am boy"); String s2=new String("I am boy"); System.out.println(sl==s2); } }

A.真

B.假

C.I am boy

D.都不正确


正确答案:B
解析:在Java语言中,“==”不仅可以用于基本数据类型之间的比较,还可以用于复合数据类型之间的比较。对于复合类型的“==”运算,其比较的目标是两个操作数是否是同一个对象,虽然题目中,a1和s2的值都是Iamboy,但是它们是不同的对象,比较后的结果应是false。如果需要比较两个对象的值是否相等,可以用equals()方法。

第5题:

顺序执行下列两条语句,输出结果是______。

String s="You are a pretty boy!";System.out.println(s.length( ));


正确答案:19
19 解析: 提取字符串的长度可以用length( )方法,它将返回字符串的字符个数。

第6题:

Which of the following underlined letters is different in pronunciation with others?

A. He arrived there half an hour late

B. Tom is the most honest boy in his class

C. I really hope to

D. It is a great honor for me to be here


参考答案:C

第7题:

若有定义 String jerry="I love Tom",s1;则s1=jerry.substring(2)的值为()

A、l

B、love

C、loveTom

D、Tom


参考答案:C

第8题:

若有定义语句: int a=5; ,则表达式: a++ 的值是 【 6 】 。


正确答案:

第9题:

以下四组表达式中,结果是逻辑值.T.的是______。

A.'this'$'this is a string'

B.'this'$'THIS IS A STRING'

C.'this is a string'$'this'

D.'this'>'this is a string'


正确答案:A
解析:在做此题前,应该首先需要了解运算符“$”的功能。该运算符的功能是测试字符串是否包含另一指定的子字符串。其格式如下:
  字符表达式1>$字符表达式2>
  如果字符表达式1>是字符表达式2>的一个子串,则结果为.T.,否则为.F.
  通过分析题目的4个选项,只有选项A的结果为.T.。选项D的含义是进行两个字符串的比较,但是其结果是.F.。

第10题:

以下4组表达式中结果是逻辑值.T.的是_________。

A.'this'$'this is a string'

B.'this'$'THIS IS A STRING'

C.'this is a string'S'this'

D.'this'>'this is a string'


正确答案:A
解析:$函数是判断前一个字符串是否包含在后一个字符串中,在字符串中大小写字符串是区分开的。所以选项B、C不正确。当比较两个字符串时,系统对两个字符串的字符自左向右逐个进行比较,一但发现两个对应字符不同,就根据这两个字符的排列序列决定两个字符串的大小。

更多相关问题