JAVA interview questions interview often often test knowledge 2

1.break, continue, return the difference between
break: out of the current cycle is no longer execute
continue: Stop when cycles back to the beginning of the cycle, the next one into the operating
return: jump statement, representation of return

2.final, finally and finalize what is the difference
final statement for the properties, methods, classes, and
finally for exception handling must be carried out represents the final
finalize expressed garbage collector to achieve resource recovery

3.assert keyword (assert) What is the role
assertions (assert) is a software debugging method provides a mechanism to detect the correctness of the code. Mainly used to ensure the correctness of the program.

4. Notes on the static keyword in
java language, static variables can not be defined in the method body
static methods can not call non-static and non-static type variable access
only internal class can be defined as static

The instance variables, local variables, static variables, final variable
instance variables: variables of all objects owned by, and initializes the default
local variables: variables defined in the body of the method, must be initialized
static variables: static modification of variables, which classify all
final variable : indicates that the variable is constant and can not be modified

6.switch keyword
latest version of java, switch began to support the String object, mainly to the return match a hash value by calling String object hashCode () method, and call String.equals () method

What is the role of 7.volatile keywords
it is designed to be modified by different threads access and modify variables. Use volatile variables, each time the system is used it is extracted directly from the corresponding memory of them and will not use the cache, avoiding the actual variable value and modify the multi-threaded application reads the values are inconsistent.

8.strictfp keyword
keyword strictfp refers to the precision floating point, which is used to ensure the accuracy of floating-point operations. JVM does not use the keyword, the results may be inconsistent on different platforms to run, if you use it to solve this problem.

Continuously updated in ...

Guess you like

Origin blog.csdn.net/fallwind_of_july/article/details/88078786