tag:blogger.com,1999:blog-8712770457197348465.post7851986428089142439..comments2024-03-18T23:01:42.768-07:00Comments on Javarevisited: Difference between Class, Instance and Local variables in Java? Examplejavin paulhttp://www.blogger.com/profile/15028902221295732276noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-8712770457197348465.post-29663226430268489182018-12-29T06:42:29.698-08:002018-12-29T06:42:29.698-08:00private CAN'T be accessed from subclass.private CAN'T be accessed from subclass.Hasan El-Hefnawynoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-65654595884604598392017-04-05T07:58:06.304-07:002017-04-05T07:58:06.304-07:00YesYesARYAN RAJhttps://www.blogger.com/profile/18397614461000045441noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-49424945831759053062016-01-30T13:24:20.608-08:002016-01-30T13:24:20.608-08:00protected instance variable can be accessed from a...protected instance variable can be accessed from another class but in same package, but only public can be accessed from another package.<br />Private instance variables can only be accessed from class which contain it or from static inner classes in outer class Anonymoushttps://www.blogger.com/profile/08767145501309068379noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-16618828148296679232013-08-13T12:12:50.068-07:002013-08-13T12:12:50.068-07:00clearly explained and it's very useful.clearly explained and it's very useful.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-88496495988325657552013-04-01T10:36:15.301-07:002013-04-01T10:36:15.301-07:00hi, javin
I would have been visiting your blog ...hi, javin <br /> I would have been visiting your blog since couple of months. It is rly very nice to me. Last weekend i encountered a question and i got stuck there. One of my frnd during his interview was asked this question and he tell me so..<br /><br />In java local variables and functions are created in stack. As a programmer we bound to initialize the local variables explicitly, why??<br /Anonymoushttps://www.blogger.com/profile/07435183617985668404noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-30239178859442717892012-12-11T18:57:26.364-08:002012-12-11T18:57:26.364-08:00Is this correct that instance variables have defau...Is this correct that instance variables have default values assigned whereas local variables are not defaulted ? Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-70720797856539533262012-02-01T16:43:51.273-08:002012-02-01T16:43:51.273-08:00That's correct class can not have local variab...That's correct class can not have local variable, but local variable can exist outside of method like static initialization block, isn't it ?javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-8090576092022145462012-02-01T07:51:06.036-08:002012-02-01T07:51:06.036-08:00I would have said a class has member fields.
http...I would have said a class has member fields.<br /><br />http://java.sun.com/docs/books/jls/third_edition/html/classes.html<br /><br />and only methods have local variables.Peter Lawreyhttps://www.blogger.com/profile/17982030676088168612noreply@blogger.com