Question: An exception is thrown.

Source: Internet
Author: User
Write a class inventoryhandler to inherit a parent class defaulthandler. The method defined in the parent class throws a saxexception: Public void fatalError (saxparserexception SPE) throws saxexception

This method is implemented in the subclass, but no exception is thrown during definition: Public void fatalError (saxparserexception SPE)

ProgramIt is strange that compilation can be performed normally.

___________________________________________________________________________

The subclass inherits the parent class. The exception thrown by the inherited method can be smaller than that thrown by the parent class, and cannot be greater than that thrown by the parent class, that is, the exception thrown by the subclass method cannot be the parent class that the corresponding method of the parent class throws, but it can be a subclass. Of course, the exception is not thrown, so the program is compiled correctly, the parent class method does not throw exceptions, and the corresponding subclass method cannot throw.

Solve the problem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.