Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question from anilbachi scjp suit

 
suman bingi
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
this is a question from anilbachi scjp suit please explain me of the solution


Thank you.
suman
 
mahesh jhamtani
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think answer will be compile time error.
Child class cannot override a method in parent class if it is more restrictive then parent class method.
In parent class method sample has public access, while in child class it has default access.
Please correct me if I am wrong.
Thanks.
 
sam pitt
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Suman Bingi,
I thought you have passed the cert. See your posting
http://www.javaranch.com/ubb/Forum24/HTML/006948.html
Have you started studying again from Anil's website? :-)
-sam pitt
 
suman bingi
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi pit,
ur first post seems interesting, Iam now preparing a collection of questions so Iam refreshing back all the material i have, and double checking them all,
any problems!!!
suman.
 
Pratap Reddy
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Suman ,
Rules of overriding is you can't make the method much
protected.
Private ---> friendly ---> protected ---> public.
But in your example public void sample() is overriding with void sample(). That not possible. It gives compiler error.
 
sam pitt
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello suman bingi,
I have no problems....
Just do not make it so obvious that other people start
noticing it !!
sam
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic