aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes my problem related to overriding 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 "my problem related to overriding" Watch "my problem related to overriding" New topic
Author

my problem related to overriding

Thakur Sachin Singh
Ranch Hand

Joined: Jun 15, 2010
Posts: 232

in kaithy seirra & bert bates book there is code which is below



SCJP 6- 91%, IBM DB2, IBM RAD Certified
Thakur Sachin Singh
Ranch Hand

Joined: Jun 15, 2010
Posts: 232

they told that there are meltdown at runtime but when i compile this program then compiler error generated...

something like this.........

*************************************************************************

eat() in Horse cannot override eat() in Animal; attempting to assign weaker access privileges; was public
private void eat()
^
1 error

Tool completed with exit code 1
**************************************************************************
Thakur Sachin Singh
Ranch Hand

Joined: Jun 15, 2010
Posts: 232

give me some suggestion what problem there.............this is the code of chapter2 page no 101 in scjp 5 by kaithy seirra & bert bates.
Thakur Sachin Singh
Ranch Hand

Joined: Jun 15, 2010
Posts: 232

book use jdk 1.5

i compile this program from jdk1.6 update 17...........
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

First read carefully rules of method overriding. Read what compiler says-
eat() in Horse cannot override eat() in Animal; attempting to assign weaker access privileges; was public
private void eat()



Life is easy because we write the source code.....
Thakur Sachin Singh
Ranch Hand

Joined: Jun 15, 2010
Posts: 232

yes i know all the rules of overriding and i also understand this error...but i want to know that...why these differences arise between book and real implementation in jdk 1.6.
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

I don't have Book right now, but I am sure It is not runtime error it gives you a compile time error.
Thakur Sachin Singh
Ranch Hand

Joined: Jun 15, 2010
Posts: 232

yes there is compile time error....i have ebook of scjp6...if you want then i send you that book on your id...after that you told me what the problem here..........
Thakur Sachin Singh
Ranch Hand

Joined: Jun 15, 2010
Posts: 232

any one give suggestion...i am confused.
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1660
    
  25

Hi Thakur,

The book states:
If this code compiled (which it doesn't), the following would fail at runtime:


Regards,
Frits
Thakur Sachin Singh
Ranch Hand

Joined: Jun 15, 2010
Posts: 232

ok thanks for reply.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: my problem related to overriding