Archive for the ‘ Sun Java Certifications ’ Category

The following table summarizes the differences between method overriding and method overloading:

Method OverridingMethod 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.

  • Share/Bookmark

ExceptionsAssertions
An exception tells the user of the program that something in the program went wrong.An assertion documents a program. When it fails, it informs that the program has a bug.
Exceptions are created to deal with problems that might occur in the program. Assertions are written to state the concepts of a program.
Exceptions are used to test input/output as well as whether parameters are legal or not.Assertions are documentations that can be checked by running the program.

  • Share/Bookmark

What are the rules for method overriding?

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.
  • Share/Bookmark

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”.
  • Share/Bookmark