I am trying to run this code and getting error illegal combination of modifiers: private and protected. Please tell me am i doing something wrong. I have read that we can use combination ot private protected access modifiers in Java HandBook then why it is showing illegal ?
Please quote the exact passage from the book. Maybe you misunderstood it or it's poorly worded.
Scope modifiers like public, protected, and private are mutually exclusive, you can have only one of them on a declaration. Other modifiers like static and final may be combined with the scope modifier.
There are better learning materials available out there. The Official Java Tutorials is a good place to start. Another free resource cited in these forums recently is this http://mooc.fi/courses/2013/programming-part-1/ which, after looking over it myself, looks pretty comprehensive in terms of materials and exercises you can complete for practice. I would stay away from that book you're using now, given the wrong information it contains.
Rahulkk Kumar wrote:If They meant 'private or protected' then the whole statement must be wrong because private member is not visible to subclass.
private member can be only use within same class where it is declared.
I missed that part about visibility in subclasses. You're right, it should only be protected then.
Good grief! That isn't a misprint at all. For one thing the format of that variable is not normal for Java®; it looks like an escape from C. In fact many older Java® applications look like C applications with a slightly different syntax.
The private protected access was only permitted in some early versions of JDK1.0. It has been removed and the combination will no longer compile. I have never seen private protected before. That book must be so old it belongs in a museum. But it is useless for learning Java® programming.
Got it Thanks for the info.
If someone searching the same and want to know what was private protected?
The meaning of private protected was to limit visibility strictly to subclasses and remove package access.
Private Protected the combination of these modifier no longer support in Java Programming due to inconsistency.
I hope it would help other
I was curious about why private protected would cause inconsistencies. I didn't find an answer to that question, but found a bit of information here:
Early on, the Java language allowed for certain combinations of modifiers, one of which was private protected. The meaning of private protected was to limit visibility strictly to subclasses (and remove package access). This was later deemed somewhat inconsistent and overly complex and is no longer supported.
 The meaning of the protected modifier changed in the Beta2 release of Java, and the private protected combination appeared at the same time. They patched some potential security holes, but confused many people.
Apparently, initially protected had the same meaning in Java as in C++ (i.e. subclasses only, not classes in the same package) but for some reason they changed that before Java 1.0 came out, and then also added private protected which was supposed to mean what protected means in C++. And then they removed that again because it was too confusing.