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