About Question enthuware.ocajp.i.v7.2.1309 :
Posted: Sat Apr 20, 2013 11:15 am
Hello!
I think you might have gotten the indenting wrong, because the TestClass class is an inner-class of the Barbie class:
However inner-classes cannot contain static members, see http://docs.oracle.com/javase/tutorial/ ... ested.html, Inner Classes paragraph, Also, because an inner class is associated with an instance, it cannot define any static members itself.
The following would be correct, given that the file is named TestClass.java:
Kind regards
I think you might have gotten the indenting wrong, because the TestClass class is an inner-class of the Barbie class:
Code: Select all
class Barbie extends Doll{
Barbie(){
//1
}
Barbie(String nm){
//2
}
public class TestClass {
public static void main(String[] args) {
Barbie b = new Barbie("mydoll");
}
}
}
The following would be correct, given that the file is named TestClass.java:
Code: Select all
class Barbie extends Doll{
Barbie(){
//1
}
Barbie(String nm){
//2
}
}
public class TestClass {
public static void main(String[] args) {
Barbie b = new Barbie("mydoll");
}
}