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

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
Elmcrest
Posts: 12
Joined: Sat Apr 20, 2013 10:06 am
Contact:

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

Post 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

admin
Site Admin
Posts: 10046
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

You are right. This has now been fixed.

thank you for your feedback!
Paul.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 31 guests