-2

Possible Duplicates:
Usage patterns for private, static, final, public, abstract keywords in java.
In Java, what's the difference between public, default, protected, and private?

what is the difference between the abstract, public, private classes?

Community
  • 1
  • 1
  • 9
    Have you searched this site before asking? – Macmade Mar 18 '11 at 05:09
  • 2
    Exact duplicate of http://stackoverflow.com/questions/5083232/usage-patterns-for-private-static-final-public-abstract-keywords-in-java – Jim Garrison Mar 18 '11 at 05:12
  • 1
    -1 (I would highly recommend a Java book/tutorial -- lists of such can be found on SO as well.) –  Mar 18 '11 at 05:15
  • @Jim it's not an *exact* duplicate if you read the other one. The other OP is asking for *usage patterns* and states from the start that he knows what they mean (except for abstract). – Michael McGowan Mar 18 '11 at 05:16

1 Answers1

1

Public classes are accessible from all other classes, whereas private classes are only accessible from within the class itself. This is a good summary of the Java visibilities:

Modifier        Class     Package   Subclass  World
public          Y         Y         Y         Y
protected       Y         Y         Y         N
no modifier     Y         Y         N         N
private         Y         N         N         N

Abstract classes are a bit of a different beast. An abstract class is one that cannot be instantiated. In other words, you cannot invoke new on an abstract class; you would need to do so an a concrete sub-class.

Michael McGowan
  • 6,528
  • 8
  • 42
  • 70