Given:
What is the output?
A. 42
B. 420
C. 462
D. 42042
E. Compilation fails.
F. An exception is thrown at runtime.
Answer: D
解析:本题主要考察String类的“+”运算符使用。String在java中定义时修饰符为final,且对+运算符进行了重载,“+”操作相当于字符串的连接。
Given:
What is the output?
A. 42
B. 420
C. 462
D. 42042
E. Compilation fails.
F. An exception is thrown at runtime.
Answer: D
解析:本题主要考察String类的“+”运算符使用。String在java中定义时修饰符为final,且对+运算符进行了重载,“+”操作相当于字符串的连接。