Wednesday 20 July 2011

brother difference between private and final ...

final & private ... in field of overriding ... they confused you too much .... now
every one knows the defination of final & private ..

final --- you can use me ... but you cant change me ...thats why i am final ....
private --- i m only visible inside a class ....

but why i am telling you these basic things ... because every big thing is built from basic concepts ...

people say that private method can inherited ... but we can not inherited final ... why ?

so the answer is .. private only allows you encapsulation ... means some protection ...thats why the private method has an signature ...and only visible inside a class .. if you declare an some method outside the class than no you found no error .. because the second method have its own unique signature ...

but what is the problem with final ... final says that ... if you want to declare me as a final then i want something that ... now you can not change me .... now you can only use me ....

changing means --- overriding
using means --- with the help of object just accessing it ( like toString() & instanceOf methods )

No comments: