• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Rules for Constructors (From Study Guide)

 
Bruce Evans
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic