aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Rules for Constructors (From Study Guide) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Rules for Constructors (From Study Guide)" Watch "Rules for Constructors (From Study Guide)" New topic
Author

Rules for Constructors (From Study Guide)

Bruce Evans
Greenhorn

Joined: Nov 28, 2004
Posts: 14
Hi,

In the Sun Certified Programmer & Developer for Java 2 Study guide on page
316 square bullet 2 under Rules for Constructors, it states: "You can access static variables and methods, although you can used them only as part of the call to super() or this(). (Example: super(Animal.DoThings())).

I have included a sample program that seems to contradict this statement.
Can someone verify which is correct, and of course, explain why.
Thanks in advance.
-Bruce

****************** program *********************


(code tags added)
[ November 29, 2004: Message edited by: Barry Gaunt ]
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
The context of Kathy and Bert's statement is during the formation of a properly constructed object. In particular, that part when the super or this constructors are being called with arguments. To form the actual values of the arguments you can only use static methods and/or variables. That's what they're getting at, they are not talking about what you can do after the object has been constructed.
[ November 29, 2004: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Rules for Constructors (From Study Guide)