Some Rules in Java:

  • A source code file can have only one public class and may have multiple non-public class
  • A public class  file name must match the public class name.
  • A file can have only one package statement and it must be the first line in the source code.
  • A file can have multiple imports.
  • Import statement is applicable to all classes in the source code file
  • If a class cannot be accessed, its members (methods and instance variables) cannot be accessed either.
  • A subclass can inherit a member of its super-class.A subclass can only extend one parent.
  • A class access determines its members' access. If a  class cannot be access, its member's cannot be accessed either.
  • 'this.' means currently executing object.
  • Private members cannot be inherited.

No comments: