Author:
Daisy Williams
Aug
19
The following table summarizes the differences between method overriding and method overloading:
| Method Overriding | Method Overloading |
|---|
| Arguments of overridden methods cannot be changed. | Arguments of overloaded methods can be changed. |
| Method return types cannot be changed except covariant return types. | Return types can be changed. |
| Exceptions must not throw new or broader checked exceptions. | Exceptions can be changed. |
| It happens at runtime. | It happens at compile-time. |
| An object type determines which method is selected. | A reference type determines which method is selected. |
Permanent link to this post (76 words, estimated 18 secs reading time)
Author:
Daisy Williams
Aug
17
According to method overriding, an overriding method must follow the following rules:
- It must have the same argument list.
- It must have the same return type, new to Java 5. The return type can be a subclass – this is known as covariant return.
- It must not have a more restrictive access modifier.
- It may have a less restrictive access modifier.
- It must not throw new or broader checked exceptions.
- It may throw fewer or narrower checked exceptions, or any unchecked exception.
Permanent link to this post (83 words, estimated 20 secs reading time)
Author:
Daisy Williams
Aug
16
JavaBean is a reusable software component that can be visually manipulated using the builder tool. The following are the JavaBean Listener naming rules:
- Listener method names that are used to register a listener with an event source must use the prefix add followed by the listener type.
- Listener method names that are used to remove a listener must use the prefix remove followed by the listener type.
- The type of listener to be added or removed must be passed as the argument to the method.
- Listener method names must end with the word “Listener”.
Permanent link to this post (95 words, estimated 23 secs reading time)