File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

my problem related to overriding

 
Thakur Sachin Singh
Ranch Hand
Posts: 242
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in kaithy seirra & bert bates book there is code which is below

 
Thakur Sachin Singh
Ranch Hand
Posts: 242
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 242
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 242
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
book use jdk 1.5

i compile this program from jdk1.6 update 17...........
 
Pramod P Deore
Ranch Hand
Posts: 632
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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()


 
Thakur Sachin Singh
Ranch Hand
Posts: 242
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 632
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 242
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 242
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any one give suggestion...i am confused.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2164
57
Android Chrome Eclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 242
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok thanks for reply.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic