It is not visible to a package outside home. And now coming to your question "why cant a class have protected access-modifier?" I think its probably because it would be no different than a default/no modifier class. Was this answer useful?Yes Reply sumanmshan ProfileAnswers by sumanmshan Mar 27th, 2008 No, We cannot hahve a "protected" class. The mind is a strange and wonderful thing.
Why Class Cannot Be Private In Java
There are only two valid declarations for a class at the namespace level, "Internal" and "Public". Problems with the examples? Why Classes cannot be declared as Protected? So if you have a class which tried to extend a Class which is visible within the package- Then I would say that one has to check the design.
public support subclass so easy to misleading. Looking for a reason behind that. if we use private or protected to the class it will give error definetly. A Class Cannot Be Private Or Protected Except Nested Class Can we declare private class in namespace Difference between Classes and Structures Can we use pointers in C# ?
so please enter the right answers and dontreply just for the sake of replying.Good Luck and Cheers
Was this answer useful?Yes Reply dipl. Plase check for inner classes in java.sun.com. Is this an SCJP question about the potential protectedness of classes? lets put it in this way: - protected top-level class would be visible to classes in its package. - now making it visible outside the package (subclasses ) is bit confusing
class itself is a member) allow, what is the outer (which contains the member) ? Protected Class Java Example Hot Network Questions Is it possible to check where an alias was defined? Compliments? share|improve this answer answered Oct 6 '10 at 4:49 Nikita Rybak 48.1k14118155 > Since there's no such concept as 'subpackage' or 'package-inheritance' in Java, declaring class protected or package-private
Can A Class Be Private In Java
suhaib mustafa Greenhorn Posts: 10 posted 4 years ago I will try to answer this question in simple terms. I want to access it from a subclass11protected data in abstract class3Why protected and private attributes are accessible by same class rather than by the same object?2How to call a method Why Class Cannot Be Private In Java Linked 1 Why can't a class be protected while it can have a default modifier in java Related 3684Is Java “pass-by-reference” or “pass-by-value”?1106Java inner class and static nested class1638In Java, difference Can A Class Be Protected In C# So the outer is package.
Classes and Packages of the Example Used to Illustrate Access Levels The following table shows where But the 3rd level default access modifier already means "package-private". What is the use case for that? A Class Cannot Be Private Or Protected In Java True Or False
The third column indicates whether subclasses of the class declared outside this package have access to the member. So If we are allowed to make a class protected then we can access it inside the package very easily but for accessing that class outside of the package we first Abimaran Kugathasan Ranch Hand Posts: 2066 I like... my review here Previous page: Using the this Keyword Next page: Understanding Class Members
Since there's no such concept as 'subpackage' or 'package-inheritance' in Java, declaring class protected or package-private would be the same thing. A Class Cannot Be Private Or Protected True Or False We cannot import it in this TestingIt.java file. Basically, for any member of a class, protected grants access to that member for subclasses of the class containing the member.
As far as I know, for a main method to be accessible there are two things you need to ensure: The enclosing class is public. (I think it can be default
You can decalre a class a public or default. I want to give access only to subclasses in different package which can extends base class(protected access). So is that what you meant to ask? What Is The Difference Between An If Statement And A Switch Statement But for subclass, visibility of parent “protected”class would be private.
Post Reply Bookmark Topic Watch Topic New Topic programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering Languages Frameworks Products This Site Careers Other all forums Forum: Programmer Certification Four access modifiers, assume the 1st level is public and 4th level is private (based on this table in sequence). A sub-class can't have the same method signature with a different implementation.I don't want my class to be inherited by any other class. get redirected here Was this answer useful?Yes Reply prakash Mar 18th, 2013 Class can be protected or private but only inner Was this answer useful?Yes Reply Raghunath Aug 16th, 2013 A class
Is it possible to sheathe a katana as a free action? With inner classes you can define protected or static which is fine with me. Paul Clapham Sheriff Posts: 21444 33 I like... because default = limited to its own package.
Previous examples of large scale protests after Presidential elections in US? share|improve this answer answered Jul 3 '14 at 15:43 madhu 1 add a comment| up vote 0 down vote @Nikita Rybak answer has good points but lack of details, i can't Paul Clapham Sheriff Posts: 21444 33 I like... Which classes should be allowed to inherit our protected class? - If all the classes are allowed to subclass then it will be similar to public access specifier. - If none
But, in the case of protected, what do you want to achieve a class with a protected modifier. Was this answer useful?Yes Reply Ranjith Mar 21st, 2006 All these discussions can be stopped now :-). For more information read Why an outer Java class can’t be private or protected share|improve this answer answered Oct 12 at 10:31 Naresh Joshi 438210 add a comment| Your Answer Build me a brick wall!
Packages- To keep the related classes together. Suggestions?