Java interview questions and summarize the basics

Basic knowledge of Java interview questions summary

1, Java in the static keyword role

(1) static variables
a) static variables in the class initial load time, will be loaded into the method area;
B) static variable is assigned as a default value in the process zone;
C) static variables before emergence objects, the general call with a class;
d) static variables are all object classes sharing;
E) static variables defined in the class can not be defined in other code blocks.

(2) static method
a), when the class is loaded, it is loaded into the method area;
B) when the method is called, executed onto the stack memory;
C) static method appears first in the subject;
D) static method can not be called directly class non-static member ;
E) can be inherited static methods, but can not be rewritten;

(3) static block
a) is static {} defined code block;
B) only in the class first initialized when executed once;
C) execution order: parent static {} - subclass static {} - parent constructor - subclass constructor

Released four original articles · won praise 0 · Views 28

Guess you like

Origin blog.csdn.net/bupt567/article/details/103996430