1 , Char can a type store a Chinese character? Why
Answer: Yes. A char is two bytes, and a Chinese is two bytes.
2 , switch SELECT statement can function in string "string", which is the ability to write: switch ( )
answer: No, can only handle Int,byte,short,char , (in fact, it can only handle int, three other types are available Promotion to the int type) cannot be processed sring .
3 , Keywords Final individually modifying a class, a method, a variable, what does each function
Answer: Final a decorated class cannot be inherited
fianl the adornment method cannot be overridden in a subclass
Final modifier variables, called constants, do not change values after initialization.
1, briefly describe the similarities and differences between synchronized and Java.util.concurrent.locks.Lock?
Answer:
Main similarities: Lock is able to accomplish the main differences in all the functions implemented by synchronized: Lock has more precise line semantics and better performance than synchronized. The synchronized automatically releases the lock, and lock must require the programmer to release it manually, and must be released in the finally clause.
2. How to format the date
Answer:
Date Now=new date ();
SimpleDateFormat sdf=new SimpleDateFormat ("Yyyy-mm-dd hh:mm:ss");
String Formatnow=sdf.format (now);
Variable Formatnow is a well-formed date.
3. Convert character "12345" to long type
Solution: String s= "12345";
Long num=long.valueof (s). Longvalue ();
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Java written test question 009