当前位置: 技术问答>java相关
java 小问题
来源: 互联网 发布时间:2015-02-07
本文导语: You need to insert an inner class declaration at line 3. Which two inner class declarations are valid?(Choose two.) A class InnerOne{ public static double methoda() {return d1;} } B public class InnerOne{ static double methoda() {return d1;...
You need to insert an inner class declaration at line 3. Which two inner class declarations are valid?(Choose two.)
A class InnerOne{
public static double methoda() {return d1;}
}
B public class InnerOne{
static double methoda() {return d1;}
}
C private class InnerOne{
double methoda() {return d1;}
}
D static class InnerOne{
protected double methoda() {return d1;}
}
E abstract class InnerOne{
public abstract double methoda();
}
为什么选CE不选AC?
A class InnerOne{
public static double methoda() {return d1;}
}
B public class InnerOne{
static double methoda() {return d1;}
}
C private class InnerOne{
double methoda() {return d1;}
}
D static class InnerOne{
protected double methoda() {return d1;}
}
E abstract class InnerOne{
public abstract double methoda();
}
为什么选CE不选AC?
|
补充yangzi(笨笨)一点,不是说内部类里就不能有静态方法。定义成static的内部类是可以有静态方法的和非静态方法的。a可改成
static class InnerOne{
public static double methoda() {return d1;}
}
static class InnerOne{
public static double methoda() {return d1;}
}
|
呵呵,你应该用排除法:
首先c肯定是对的,
然后看E,一个抽象类当然可以做内部类,而在它里只能有抽象的方法。
a有问题,内部类里不能有静态方法。
首先c肯定是对的,
然后看E,一个抽象类当然可以做内部类,而在它里只能有抽象的方法。
a有问题,内部类里不能有静态方法。
|
不过正如yangzi所说,内部类里不能有静态方法。我试了