格林模拟试题一参考答案Java认证考试
文章作者 100test 发表时间 2009:04:30 07:58:49
来源 100Test.Com百考试题网
answer 1)
5) int i=10.
explanation:
1) float f=1.3.
will not compile because the default type of a number with a floating point component is a double. this would compile with a cast as in
float f=(float) 1.3
2) char c="a".
will not compile because a char (16 bit unsigned integer) must be defined with single quotes. this would compile if it were in the form
char c= a .
3) byte b=257.
will not compile because a byte is eight bits. take of one bit for the sign component you can define numbers between
-128 to 127
4) a boolean value can either be true or false, null is not allowed
answer 2)
1) can t make static reference to void amethod.
because main is defined as static you need to create an instance of the class in order to call any non-static methods. thus a typical way to do this would be.
myclass m=new myclass().
m.amethod().
answer 2 is an attempt to confuse because the convention is for a main method to be in the form
string argv[]
that argv is just a convention and any acceptable identifier for a string array can be used. answers 3 and 4 are just nonsense.