Learning Source: http://www.cnblogs.com/chenssy/p/3354884.html
Defaults default permissions (package permissions-the same package can be accessed)
Private (the class can be used internally, and inherited subclasses cannot access it)
Protected (classes and packages can be accessed internally, and their subclasses can also be accessed)
Public any can access
Permission adornments for class can be used only with public and default
Inherited
Implementing the inheritance mechanism of a class using the extends keyword in Java
By inheritance, subclasses automatically have all members of the base class (superclass)
Java only supports single inheritance and does not allow multiple inheritance
classperson{PrivateString name; Private intAge ; Public voidsetName (String name) { This. Name =name; } Public voidSetage (intAge ) { This. Age =Age ; } PublicString GetName () {returnname; } Public intGetage () {returnAge ; }}classStudentextendsPerson {PrivateString School; Public voidSetschool (String school) { This. School =School; } PublicString Getschool () {returnSchool; }}/*** * Implementation of class inheritance mechanism using extends keyword in Java * through inheritance, subclasses automatically have all members of the base class (superclass) * Java only supports single inheritance and does not allow multiple inheritance*/ Public classExtendtest { Public Static voidMain (string[] args) {Student Student=NewStudent (); Student.setname ("Jone"); Student.setage (18); Student.setschool ("SCH"); System.out.println (Student.getname ()); System.out.println (Student.getage ()); System.out.println (Student.getschool ()); } }
Understanding the inheritance of three major features of Java