![]() |
|
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
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.
转贴于:Java认证考试_考试大 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]