java_day05 Java Basics

Source: Internet
Author: User

1. The difference between abstract and generic classes:
1) abstract class using the abstraction modifier
2) Abstract classes cannot be instantiated
3) Abstract classes can have abstract methods, or there can be no abstract method


2.-Use interface statement
-Interfaces are a collection of abstract methods and constants, and no other components
-the method in the interface is decorated as public abstract by default
-The default decoration for constants in an interface is public static final
-Implement interface using implements keyword
-A class can implement multiple interfaces, with multiple interfaces separated by commas
-Interfaces can inherit between
-If a class implements both an interface and a parent class, extends is placed in front of implements


3. How to create an inner class object outside the class:
-For non-static inner classes: You must first create an outer class object, and then create an inner class object
-For static inner classes: The inner class is decorated with static, so the object that creates the class can have no external class object


4. Throw an exception after the method parameter list using the throws keyword declaration, the exception is not processed inside the current method, and the method that calls the current method is thrown


5.-Throws can declare multiple exceptions to be thrown separated by commas, with multiple exceptions without order
-Can declare the parent class of the exception class that throws the occurrence
-overriding methods cannot throw exceptions that are larger than overridden methods (non-runtime exceptions)


6. Custom Exceptions:
-Typically inherited runtimeexception
-function: See the meaning of the name
-Usually you need to use the throws keyword to throw


java_day05 Java Basics

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.