试题如下
参考答案
importar java.io.filenotfoundException; importar java.io.ioException; importar java.util.arraylist; importar java.util.concurrent.executorService; importar java.util.concurrent.executores;/** ** criado por ysc em 7/26/16. */public classe entrevista {private static void One () {string str1 = "hello"; String str2 = "ele"+nova string ("llO"); System.err.println (str1 == str2); System.out.println ("1. False"); } private estático void dois () {int i = Integer.max_value; System.err.println ((i+1) <i); System.out.println ("2. 存在一个 i, 使得 (i+1) <i"); } private estático vazio três () {System.err.println ("GC não é um thread java, é um thread nativo"); Thread.getAllStackTRACS (). KeySet (). Foreach (thread -> system.out.println (thread.getName ()+" ->"+thread.isdaemon ()+""+thread.getPriority ())); System.out.println ("3. GC 线程是 Daemon 线程"); } private estático volátil int contagem = 0; private static void Four () {ExecutSorService ExecorService = Executores.NewCachedThreadpool (); para (int j = 0; j <10; j ++) {ExecutorService.submit (()-> {for (int i = 0; i <1000000; i ++) {count ++;}}); } System.out.println ("contagem deve ser:" +10000000+ ", be:"+contagem); System.out.println ("4. Volátil 不能保证线程安全"); } private static void cinco () {ArrayList <Teger> list = new ArrayList <> (20); list.add (1); System.out.println ("Código de depuração, não execute o método Grow"); System.out.println ("5. Lista cresce 0 vezes"); } private static void six () {System.out.println ("Construtor do BufferReader aceita apenas uma instância do leitor"); System.out.println ("6. New BufferReader (new FileInputStream (/" A.Dat/")); está errado"); } private static void sete () {tente {if (true) {tiro novo ioexception (); }} catch (filenotfoundException e) {System.out.print ("fileNotfoundException!"); } catch (ioexception e) {System.out.print ("IoException!"); } catch (Exceção e) {System.out.print ("Exceção!"); } System.out.println ("/n7. IoException!"); } private estático void oito () {System.out.println ("String s System.out.println ("8. 由于 String S 没有初始化, 代码不能编译通过"); } private static void nine () {System.out.println ("5" +2); System.out.println ("9. 52"); } private static void ten () {int i = 2; int resultado = 0; switch (i) {case 1: resultado = resultado + i; caso 2: resultado = resultado + i * 2; Caso 3: resultado = resultado + i * 3; } System.out.println ("resultado ="+resultado); System.out.println ("10. 10"); } classe estática privada null {public static void hello () {System.out.println ("hello"); } public static void main (string [] args) {((null) null) .hello (); Null _null = (null) null; _null.hello (); }} classe estática privada StringExample1 {String str = new String ("Good"); char [] ch = {'a', 'b', 'c'}; Public Void Change (String str, char [] ch) {str = "teste ok"; ch [0] = 'g'; } public static void main (string [] args) {stringExample1 ex = new StringExample1 (); Ex.Change (Ex.STR, Ex.CH); System.out.print (Ex.Str+"e"); System.out.print (Ex.CH); System.out.println (); }} classe estática privada stringExample2 {public static void alteração (string str) {str = "Welcome"; } public static void main (string [] args) {string str = "1234"; mudança (str); System.out.println (str); }} classe estática privada forloop {estático booleano foo (char c) {system.out.print (c); retornar true; } public static void main (string [] args) {int i = 0; para (foo ('a'); foo ('b') && (i <2); foo ('c')) {i ++; comida'); } System.out.println (); }} classe estática privada helloa {public helloa () {system.out.println ("helloa"); } {System.out.println ("Sou uma classe"); } static {System.out.println ("static a"); }} classe estática privada Hellob estende Helloa {public Hellob () {System.out.println ("Hellob"); } {System.out.println ("I'm B class"); } static {System.out.println ("static b"); } public static void main (string [] args) {System.out.println ("principal start"); New Hellob (); New Hellob (); System.out.println ("End Main"); }} public static void main (string [] args) {One (); dois(); três(); quatro (); cinco(); seis(); Sete(); oito(); nove(); dez(); Null.main (nulo); StringExample1.main (nulo); StringExample2.Main (NULL); Forloop.main (nulo); Hellob.Main (NULL); }}以上就是本文的全部内容 , 希望对大家的学习有所帮助 , 也希望大家多多支持武林网。