Java Surface Question--java basic article

Source: Internet
Author: User

1. How to implement Java polymorphism: Inherit, Reload, overwrite

2. Java has 8 basic data types: Byte, short, int, long, float, double, Boolean, CHAR3, final, finally, Finalize, final: modifier, If a class is declared final, it means that it can no longer derive a new subclass. A class cannot be declared both abstract and final. Declaring variables or methods as final ensures that they are not changed in use. A variable declared as final must be given an initial value at the time of declaration, and can only be read in subsequent references and cannot be modified. The method that is declared final is also used only and cannot be overloaded. Finally: In exception handling, the last part that must be executed. The Finalize:finalize () method is a call to this object before the garbage collector deletes the object. 4. Difference between & and &&:& is a bitwise operator,&& is a boolean logical runner. 5. The difference between HashMap and Hashtable: Classes that belong to the map interface implement a unique key mapping to a specific value. HashMap classes are not categorized or sorted. It runs a null key and multiple null values. Hashtable is similar to HashMap, but it does not run null keys and null values. It is also slower than HashMap, because it is synchronous. 6. What are the aspects of object-oriented features: Abstraction: Abstraction is the omission of aspects of a topic that are not relevant to the current goal, in order to pay more attention to the aspects related to the current goal. Abstract includes two aspects, one is the process abstraction, Es according to abstract. Inheritance: Encapsulation:encapsulation is the process and data surrounding it. Polymorphism: Polymorphism means that objects of different classes are allowed to respond to the same message. Polymorphism consists of parameterized polymorphism and inclusion polymorphism. Polymorphism language has the advantage of flexibility, abstraction, behavior sharing and code sharing, which solves the problem of application function with the same name. 7. The difference between error and exception: error indicates a serious problem in situations where recovery is not impossible but difficult. For example, memory overflow. It is impossible to expect the program to handle such situations. Exception represents a design or implementation issue. That is, it means that if the program runs normally, it never happens. 8. The difference between string and StringBuffer: The Java platform provides two classes: string and StringBuffer, which can store and manipulate strings, that is, character data that contains multiple characters. This string class provides a string of values that cannot be changed. The string provided by this StringBuffer class is modified. You can use StringBuffer when you know that character data is going to change. Typically, you can use Stringbuffers to dynamically construct character data. 9. What is the difference between a runtime exception and a general exception: An exception indicates an abnormal state that may occur during a program's operation, and a run-time exception that represents an exception that may be encountered in a virtual machine's usual operation, which is a common run error. The Java compiler requires the method to declare a non-runtime exception that might occur, but does not require that a runtime exception that is not caught to be thrown must be declared.



From for notes (Wiz)



Java Surface Question--java basic article

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.