Page 1 of 1

About Question enthuware.ocajp.i.v7.2.1309 :

Posted: Sat Apr 20, 2013 11:15 am
by Elmcrest
Hello!

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");
       }
   }
}
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:

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");
    }
}
Kind regards

Re: About Question enthuware.ocajp.i.v7.2.1309 :

Posted: Sat May 11, 2013 2:57 pm
by admin
You are right. This has now been fixed.

thank you for your feedback!
Paul.