· Has-A relationship is when we create a instance of the class B, Has-is when we extend or inherit.
· Either this or super can be called as the first line from within
a constructor, but not both.
· Constructors cannot be overridden, and cannot be inherited.
· Subclass cannot access private members of the super class
· If A extends B, and A a = new B (); then a. variable is from right object and a. method is from left, and a constructer similar to B is created in A and called.
· The argument list must exactly match that of the overridden method. If they don't match, you can end up with an overloaded method you didn't intend.
· The return type must be the same as, or a subtype of, the return type declared in the original overridden method in the super class
· The access level can't be more restrictive than the overridden method's.
· The access level CAN be less restrictive than that of the overridden method.
· Instance methods can be overridden only if they are inherited by the subclass.
· A subclass within the same package as the instance's super class can override any super class method that is not marked private or final.
· A subclass in a different package can override only those non-final methods marked public or protected
· The overriding method CAN throw any unchecked (runtime) exception, regardless of whether the overridden method declares the exception.
· The overriding method must NOT throw checked exceptions that are new or broader than those declared by the overridden method. For example, a method that declares a FileNotFoundException cannot be overridden by a method that declares a SQLException, Exception, or any other non-runtime exception unless it's a subclass of FileNotFoundException.
· The overriding method can throw narrower or fewer exceptions. Just because an overridden method "takes risks" doesn't mean that the overriding subclass' exception takes the same risks. Bottom line: an overriding method doesn't have to declare any exceptions that it will never throw, regardless of what the overridden method declares.