aspose file tools*
The moose likes Beginning Java and the fly likes asking about public private n protected Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "asking about public private n protected" Watch "asking about public private n protected" New topic
Author

asking about public private n protected

kumar abhay
Ranch Hand

Joined: Oct 02, 2001
Posts: 53
hi there,
i hopr u r doing fine,had to ask something,given below:
case 1 :private class Ss{
case 2 :protected class Ss{
case 3 :public class Ss{
my question is
In case 1 error is genereted why
In case 2 erroe is genereted why
in case 3 there is no error why
please tell me that wat is the basic difference b/w them n why in two cases error is genereted n in last case there is no error.i hope that u ppl will help me asap.
take care
with regards
kumar abhay
[This message has been edited by Cindy Glass (edited November 26, 2001).]
kumar abhay
Ranch Hand

Joined: Oct 02, 2001
Posts: 53
note:question was written wrong by mistake so it is the same question with nothing missing.
hi there,
i hopr u r doing fine,had to ask something,given below:
case 1 private class Ss{
case 2 protected class Ss{
case 3 public class Ss{
my question is
In case 1 error is genereted why
In case 2 erroe is genereted why
in case 3 there is no error why
please tell me that wat is the basic difference b/w them n why in two cases error is genereted n in last case there is no error.i hope that u ppl will help me asap.
take care
with regards
kumar abhay
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9047
    
  10
In Java, a top level class may only be public or default (no access modifier). You may not declare a class private or protected unless it is an inner class.

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
kumar abhay
Ranch Hand

Joined: Oct 02, 2001
Posts: 53
hi there,
could u make it more clear plz.
take care
with regards
kumar abhay
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9047
    
  10
<pre>
public class myClass{} // OK
class myClass{} // OK
protected class myClass{} // not allowed in Java
private class myClass{} // not allowed in Java

If you want to know why they are not allowed, you will have to ask James Gosling, the creator of the Java language.

class Outer
{
private class InnerOne{} // OK
protected class InnerTwo{} // OK
class InnerThree{} // OK
public class InnerFour{} // OK
}
Inner classes are different.
</pre>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: asking about public private n protected