格林模拟试题一参考答案

来源:java认证发布时间:2012-11-12 12:47:44java认证视频

 

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.

上一页123456下一页

视频学习

我考网版权与免责声明

① 凡本网注明稿件来源为"原创"的所有文字、图片和音视频稿件,版权均属本网所有。任何媒体、网站或个人转载、链接转贴或以其他方式复制发表时必须注明"稿件来源:我考网",违者本网将依法追究责任;

② 本网部分稿件来源于网络,任何单位或个人认为我考网发布的内容可能涉嫌侵犯其合法权益,应该及时向我考网书面反馈,并提供身份证明、权属证明及详细侵权情况证明,我考网在收到上述法律文件后,将会尽快移除被控侵权内容。

最近更新

社区交流

考试问答