posted 23 years ago
. Given:
public class OuterClass {
private double d1 = 1.0;
//insert code here
}
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();
}
the correct answers are c and e.
can anyone xplain the other options as i am a little confused.
are a) and b) wrong cause inner classes cant have static methods ot wht???
and wht abt d) , is it bcause the method is protected or wht ??
or is it bcause the inner class is static ???
pls xplain the reasons for all options if possible, even the correct ones cause i inner classes r very confusin
thx a lot
regards
Kamal