public class ClassA {
43. public int getValue() {
44.int value=0;
45. boolean setting = true;
46. String title=”Hello”;
47. if (value || (setting && title == “Hello”)) { return 1; }
48. if (value == 1 & title.equals(”Hello”)) { return 2; }
49. }
50. }
And:
70. ClassA a = new ClassA();
71. a.getValue();
What is the result?
A. 1
B. 2
C. Compilation fails.
D. The code runs with no output.
E. An exception is thrown at runtime.
我感觉结果应该是1,可是答案是C,请给位详细解答下。另外if(value)可以判断吗?
43. public int getValue() {
44.int value=0;
45. boolean setting = true;
46. String title=”Hello”;
47. if (value || (setting && title == “Hello”)) { return 1; }
48. if (value == 1 & title.equals(”Hello”)) { return 2; }
49. }
50. }
And:
70. ClassA a = new ClassA();
71. a.getValue();
What is the result?
A. 1
B. 2
C. Compilation fails.
D. The code runs with no output.
E. An exception is thrown at runtime.
我感觉结果应该是1,可是答案是C,请给位详细解答下。另外if(value)可以判断吗?
解决方案 »
- 打开选择文件窗口过滤条件的顺序问题
- Java wumpus的游戏设计
- 急 急 急 sql2008连接问题
- 哪位有JAVA编程思想第四版的书上源代码?
- 调查一下,各位java程序员你以前是学什么的
- 各位高手!在哪可以找到些java啊applet圖形動畫方面的資料啊!幫幫忙,謝了啊!
- 请教关于java源码防止反编译问题
- 用java 重word中读数据同时写到另一个word文件中,请帮忙?代码如下:
- 兩個對象都是用DatagramSocket監視同一個端口,但其中一個的DatagramSocket不能創建,這是為什麼,怎麼解決這個問題?
- 用Rose逆向从java代码生成模型的错误:Error Resolving qualified name String occured in File...
- 高人指点下~~~十万火急
- 在线等,在线给分!!高手过来看看!!
不像c