This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes 4m Dan's Exam Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "4m Dan Watch "4m Dan New topic
Author

4m Dan's Exam

Mohit Agarwal
Ranch Hand

Joined: Mar 30, 2004
Posts: 88
The code is from Dan's Exam :


Pls. clear it.

Mohit Agarwal.
Would be SCJP.
"The will to win is worthless if u do not have the will to prepare"
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Try to analyze it keeping in mind that an interface's constants are only initialized when they are actually needed.

v is certainly needed because it is printed, but are E.w, F.x, F.y and F.z?
[ October 04, 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.
Mohit Agarwal
Ranch Hand

Joined: Mar 30, 2004
Posts: 88
Yes, Bary that's what i find out when i experimented with the code,
but really i don't know that "an interface's constants are only initialized when they are actually needed. "
But they are implicitly final vars which are to be initialized befor the constructor completes .

I had read this. I am using kathy and Bert.

Pls. clear it more.


Mohit Agarwal.
Would be SCJP.
"The will to win is worthless if u do not have the will to prepare"
Tom Tolman
Ranch Hand

Joined: Sep 02, 2004
Posts: 83
Try the following code out:

kapil munjal
Ranch Hand

Joined: May 11, 2004
Posts: 298
Hi Tom,

I have tried your code and it runs without any problem but my question is " why it doesn't print 'w'?".

I know it is in the parent interface of E, but when child interface is executed then why not Parent interface.


Kaps


Kapil Munjal
SCJP 1.4, SCWCD 1.4
Mohit Agarwal
Ranch Hand

Joined: Mar 30, 2004
Posts: 88
I am sorry Tom i didn't get your point.
Moreover my Q remains unanswered.
Pls. let me know about that.


Mohit Agarwal.
Would be SCJP.
"The will to win is worthless if u do not have the will to prepare"
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
The answer to your question lies in this section of JLS

What Tom's example points out is that when an interface is initialized (because one of the members in used) then all of the members of the interface are initialized in texual order.

And that superinterfaces are not necessarily initialized when extension interfaces are.
[ October 05, 2004: Message edited by: Barry Gaunt ]
 
 
subject: 4m Dan's Exam