Please enable JavaScript.
Coggle requires JavaScript to display documents.
Class Design (Tip (Override parent class method in child class method (Be…
Class Design
-
-
Constructors
-
Rules
1 - First statement of every constructor is a call to another constructor. It can be this() or super().
-
3 - If no super() call is declared in a constructor, Java will insert a no-argument super() as the first statement of the constructor.
4 - If the parent doesn't have a no-argument constructor and the child doesn't define any constructors, the compiler will throw an error and try to insert a default no-argument constructor into the child class.
5 - If the parent doesn't have no-argument constructor, the compiler requires an explicit call to a parent constructor in each child constructor.
-
-
-
Inheriting Methods
Overriding Methods
Rules
-
2 - The method in the child class must be at least as accessible or more accessible than the method in the parent class.
3 - The method in the child class may not throw a checked exception that is new or broader than the class of any exception thrown in the parent class method.
4 - If method returns a value, it must be the same or a subclass of the method in the parent class, known as covariant return types.
-
-
-