2009年2月3日 星期二

第1題SampleCode

Given:
35. String #name = "Jane Doe";
36. int $age = 24;
37. Double _height = 123.5;
38. double ~temp = 37.5;
Which two statements are true? (Choose two.)
A. Line 35 will not compile.
B. Line 36 will not compile.
C. Line 37 will not compile.
D. Line 38 will not compile.
答案:AD
參考:2-4 Java 程式內容簡介

------------------------------------------------------
public class SCJP6001 {
public static void main(String[] args) {
String #name = "Jane Doe";
int $age = 24;
Double _height = 123.5;
double ~temp = 37.5;
}
}

ANS:
A. Line 35 will not compile.
D. Line 38 will not compile.
-------------------------------------------------------------------------------------
My Answers:
35. String #name = "Jane Doe";
Syntax error on token "Invalid Character", delete this token
38. double ~temp = 37.5;
Syntax error on token "~", delete this token


Java variable names must start with one of the following characters:
• Letter
• Underscore
• Dollar sign
-------------------------------------------------------------------------------------

沒有留言:

張貼留言