w*n
2 楼
If name is a String instance variable, average is a double instance variable
, and numOfStudents is a static int variable, why won’t the following code
from a class compile?
public Student(String s)
{
name = s;
average = getAverage(name);
numOfStudents++;
}
public double getAverage(String x)
{
numOfStudents++;
double ave = StudentDB.getAverage(x);
return ave;
}
public static void setAverage(double g)
{
average = g;
}
Answer
a.
The setAverage method can’t access the average instance variable.
b.
The getAverage method can’t increment the numOfStudents variable.
c.
The constructor can’t increment the numOfStudents variable.
d.
The getAverage method can’t call a static method in the StudentDB class.
, and numOfStudents is a static int variable, why won’t the following code
from a class compile?
public Student(String s)
{
name = s;
average = getAverage(name);
numOfStudents++;
}
public double getAverage(String x)
{
numOfStudents++;
double ave = StudentDB.getAverage(x);
return ave;
}
public static void setAverage(double g)
{
average = g;
}
Answer
a.
The setAverage method can’t access the average instance variable.
b.
The getAverage method can’t increment the numOfStudents variable.
c.
The constructor can’t increment the numOfStudents variable.
d.
The getAverage method can’t call a static method in the StudentDB class.
k*6
4 楼
a
G*e
6 楼
显然是选A。
建议楼主想想java程序是怎么运行的。特别是想想你在编译完后,在执行.class文件的
时候发生了什么事情。 我是java的菜鸟。恰好最近看了一些这方面的东西。
建议楼主想想java程序是怎么运行的。特别是想想你在编译完后,在执行.class文件的
时候发生了什么事情。 我是java的菜鸟。恰好最近看了一些这方面的东西。
z*e
8 楼
我也觉得是a,可以考虑这么一个scenario,没有任何object的时候,调用这个ClassX.
getAverage(1.0),没有object,也就没有object的average member variable.出错了
getAverage(1.0),没有object,也就没有object的average member variable.出错了
n*t
10 楼
你那个StudentDB.getAverage(x); 是不是打错了, 应该是StudentDB.setAverage(x);
n*t
12 楼
StudentDB.getAverage(x); 是不是写错了, 应该是StudentDB.setAverage(x);
要不然就自己调用自己了.
在一个static 方法中引用任何实例变量都是非法的, 除非你的变量都是static,或者
不要定义为static method.
要不然就自己调用自己了.
在一个static 方法中引用任何实例变量都是非法的, 除非你的变量都是static,或者
不要定义为static method.
l*p
14 楼
类一实现,static进内存
average非static还没建立,无法访问
variable
code
【在 w*********n 的大作中提到】
: If name is a String instance variable, average is a double instance variable
: , and numOfStudents is a static int variable, why won’t the following code
: from a class compile?
: public Student(String s)
: {
: name = s;
: average = getAverage(name);
: numOfStudents++;
: }
: public double getAverage(String x)
average非static还没建立,无法访问
variable
code
【在 w*********n 的大作中提到】
: If name is a String instance variable, average is a double instance variable
: , and numOfStudents is a static int variable, why won’t the following code
: from a class compile?
: public Student(String s)
: {
: name = s;
: average = getAverage(name);
: numOfStudents++;
: }
: public double getAverage(String x)
a*o
15 楼
没有,钨还是不太贵,记得跟银子差不多,不过那是中国的价,中国有大钨矿,随便刨
刨就一堆钨酸盐,价钱主要都是生产成本。美国就不知道了。
我觉得造币模子够呛用含钨材料。所有含钨材料都很难精密锻造,太难handle了。
我怀疑是高碳钢,硬度足够了,破金子银子在高碳钢面前就跟纸糊的一样。
我见过的钨料都是特简单的形状,纯钨不是棍子就是敦子,要不就是钨丝。
拉钨丝的模子是碳化钨做的,比钨还NB。
【在 m*****u 的大作中提到】
: 99.9的钨应该比99.9的金子贵吧?
: 钨很硬, 打金币的模子会不会是钨钢做得? 俺有点想去造币厂参观一下
: 金币造假不太容易, 用钯,银, 铅这种容易handle的 1oz重量的玩意要大出好大一圈
刨就一堆钨酸盐,价钱主要都是生产成本。美国就不知道了。
我觉得造币模子够呛用含钨材料。所有含钨材料都很难精密锻造,太难handle了。
我怀疑是高碳钢,硬度足够了,破金子银子在高碳钢面前就跟纸糊的一样。
我见过的钨料都是特简单的形状,纯钨不是棍子就是敦子,要不就是钨丝。
拉钨丝的模子是碳化钨做的,比钨还NB。
【在 m*****u 的大作中提到】
: 99.9的钨应该比99.9的金子贵吧?
: 钨很硬, 打金币的模子会不会是钨钢做得? 俺有点想去造币厂参观一下
: 金币造假不太容易, 用钯,银, 铅这种容易handle的 1oz重量的玩意要大出好大一圈
相关阅读
找不到Word.* 和 Project.*java dumb question Re: Help!: tomcat classloading problemhow to edit autoexec.batHelp! J2ee online test?how do you debug java applet?Re: transfer files over Internet有没有办法阻止别人下载applet的.class文件?a synchonized problem!weird class definition第一个VJ++程序"Hello World"的问题快被java整疯了 求助呀Help me: jsp tag 问题Eclipse 3.0出来了.求救——java.lang.NoClassDefFoundErrorObject scope questionchange JSlider thumb icon?Getting bytecode of a classCan Java call C libraries?Help!: tomcat classloading problem