SCJP Certification

Sun Certified Java Programmer Certification exam essentials

August 17th, 2010

What are the rules for method overriding?

Sun Java Certifications, by Daisy Williams.

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

Back Top

Responses to “What are the rules for method overriding?”

Comments (0) Trackbacks (0) Leave a comment Trackback url
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Your email address will not be published. Required fields are marked *

*