Dark Horse Programmer _java Basic Knowledge Summary 3

Source: Internet
Author: User
Tags try catch

    1. The Java source file extension is. java, which generates a. class file after compilation. All classes have a common inheritance ancestor object class
    2. There can be only one public class in a. java file, and a public class can only be defined in a file named after its class name
    3. The Implement keyword is used to implement interfaces, and classes can implement multiple interfaces, inheriting the use of the extends keyword
    4. Package for better organization of Java programs, packages provide a namespace for Java programs, and the full path of a Java class consists of its package and class name.
    5. The Java class or no public keyword indicates that the class is visible in the package in which it resides, which is the default access permission in Java
    6. Package, put the compiled class file under the corresponding path, and then use the import statement to refer to the
    7. The Super keyword is used to refer to a base class object, in which a class member can be accessed with super, and if the subclass has a function of the same name, the child class member is called when called outside the class
    8. The basic meaning of the final keyword is that the data/method/class cannot be changed.
      Final basic type of data: fixed value (constant value), can only be assigned once and can no longer be modified.
      Final method: The method cannot be overwritten. The private method defaults to the final method.
      Final class: The class cannot be inherited.
    9. There is a single inheritance between classes in Java, but multiple interfaces can be inherited
    10. The abstract,static,string keyword in Java is the same as in C #, as is the function parameter passing rule
    11. Java refers to the role of pointers, there is a stack but cannot modify the value of the pointer, such as the C language as the pointer + + operation is not allowed, such as Human man = new Human (), the man is a reference to the Human object created in the heap
    12. Garbage collection: Empty object memory is recycled when no reference is directed to the object
    13. Exception classes in Java inherit from the Trowable class
    14. The class class is the abstract of the classes, no matter what kind of conversion we make to the reference, the object itself is the same class object, like the metadata in C #, the role of reflection
    15. Synchronized is the modifier of the method. In Java, the synchronized method of the same object can be called only by one thread at a time. Other threads must wait for the thread call to end, (the remaining thread one) to run, and synchronized has the same usage as C # lock
    16. Internal class Rules:
      • An inner class can directly access external class members, including private members, in the following notation: external class name. This. External member name
      • An external class accesses an inner class, and an inner class object must be established to create an inner class object that must first establish an outer class object
      • When an inner class is statically decorated, only static members in the outer class can be accessed
    17. In the Java generics? Indicates the type is indeterminate, list<?>list
    18. Runtime exception is the system operation times out of the exception, is the system internal adjustment mechanism reported, such as system memory overflow. Non-runtime exceptions are exceptions caused by improper program writing, the most common null pointer exceptions, array subscripts exceeding exceptions, and so on.

    19. Throws throws an exception if the exception is an inherited runtimeexception, you do not need to force you to write a try catch statement to ensure that the exception being thrown is handled. If you inherit exception, you will need a try catch statement to ensure that exceptions are handled, and common run-time exceptions are:
      • ClassCastException (class conversion exception)
      • Indexoutofboundsexception (array out of bounds)
      • NullPointerException (null pointer)
      • Arraystoreexception (data store exception, type inconsistency when manipulating arrays)

    20. Import static import is a new feature in JDK1.5. Generally we import a class with import com ..... ClassName, while static import is this: import static com ..... Classname.*, there is more static here, there is a class name ClassName behind more. *, which means to import static methods in this class. Of course, you can just import a static method, just change the. * to a static method name. Then in this class, you can call the static method directly with the method name, rather than using the ClassName. Method name.

Dark Horse Programmer _java Basic Knowledge Summary 3

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.