This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
hi friends what is the exact difference between protected and default access modifiers? as i know that "protected" can be accessible only from subclasses regardless of whether that class is in same package or not and "default" can be accessible from any class in the same package regardless of whether that is extended or not.
Base t = new Base(); t.method2(); System.out.println("asdf");
output is: Base method2 asdf
so, that means a class can access protected members without extending if that class in same package. is it write?(still i cann't believe) give me clarification whether it is write or any other involved.....
Thanks & Regards<br />Mallik Avula<br />SCJP1.4
Joined: Nov 30, 2006
hi friends i am very sorry for small mistake is it right? not(is it write) i am really very sorry
Access Specifier scope -------------------------------------------- "public" scope protected access + any other outer pack classes "protected" scope default pack access + any sub class relation "default" scope (means absence of access specifier)-- classes in same pack "private" - methods in same class in which its defined.