Java written test question 007

Source: Internet
Author: User

Java written test question 007


1, please use regular expression to match the QQ number (assuming QQ number is 5-10-bit);

Answer: ^ \d{5,10}$


2, String, StringBuffer StringBuilder difference.

Answer: The length of the string is immutable, the length of the StringBuffer is variable, if you are working on the contents of the string frequently, especially when the content is to be modified, then use StringBuffer, if the last string is required, Then use the ToString () method of StringBuffer, thread safety;

StringBuilder is starting with JDK 5, which complements the equivalence class used by a single thread for the StringBuffer class;

The StringBuilder class, because it supports all the same operations, but is faster because it does not perform synchronization.


3, please write out 5 kinds of common to the runtime exception.

Answer:

NullPointerException: This error occurs when you manipulate a null reference.

NumberFormatException: This exception occurs when there is a problem with the data format conversion.

ClassCastException: This exception occurs when coercion type conversion types do not match.

ArrayIndexOutOfBoundsException: Array subscript is out of bounds when this exception occurs when using an array subscript that does not exist.

ArithmeticException: This exception occurs when math runs incorrectly




Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Java written test question 007

Related 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.