aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt in ExamLab 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 "Doubt in ExamLab " Watch "Doubt in ExamLab " New topic
Author

Doubt in ExamLab

Fissehaye Kahsay
Greenhorn

Joined: May 26, 2009
Posts: 9

shouldn't the output of the above code be "DemoC++". We are using super.s, so the upper class XClass has no knowledge about the subclass YClass. Any help please and takes for your time
Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531
i guess you are using the super keyword wrong...super is used when a variable in the current class shadows the variable in the superclass.....try this example...then may you will understand....am not sure if am right....what i have done here is created a new string s in the YClass.....
Dejan Miler
Ranch Hand

Joined: Nov 14, 2009
Posts: 56
Hello guys.


Here we just accessing to superclass variable and give it new value and that happens before this line of code

And that is all.

Dejan.


SCJP 1.6 in progress ....
Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531
Dejan is absolutely right.....bang on target...we have changed the value of superclass's variable and using super.s we are trying to find out the value of s..which is c#....
Ajit Sawant
Ranch Hand

Joined: Nov 26, 2008
Posts: 33
Concept that is being show is that at the time of object creation initializwer are executed and that the super class intializer in run before the subclass. Actually the intializer is run before it own constructor is run.

Ajit
 
jQuery in Action, 2nd edition
 
subject: Doubt in ExamLab