试题如下 :
参考答案 :
import java.io.filenotfoundexception; import java.io.ioexception; import java.util.arraylist; import java.util.concurrent.executorservice; import java.util.concurrent.executors;/*** 7/26/16에서 생성. */public class 인터뷰 {private static void one () {String str1 = "Hello"; 문자열 str2 = "He"+new String ( "llo"); System.err.println (str1 == str2); System.out.println ( "1. false"); } private static void 2 () {int i = integer.max_value; System.err.println ((i+1) <i); System.out.println ( "2. 存在一个 i, 使得 (i+1) <i"); } private static void 3 () {System.err.println ( "GC는 Java 스레드가 아니며 기본 스레드입니다"); Thread.getallStackTraces (). Keyset (). foreach (스레드 -> system.out.println (thread.getName ()+" ->"+thread.isdaemon () "+thread.getPriority ()); System.out.println ( "3. gc 线程是 daemon 线程"); } 개인 정적 휘발성 int count = 0; private static void four () {executorService executorService = executor.newCachedThreadPool (); for (int j = 0; j <10; j ++) {executorService.submit (()-> {for (int i = 0; i <10000000; i ++) {count ++;}}); } system.out.println ( "count는 다음과 같아야합니다 :"+10000000+ ", 실제 be :"+count); System.out.println ( "4. 휘발성 不能保证线程安全"); } private static void 5 () {arraylist <integer> list = new arraylist <> (20); list.add (1); System.out.println ( "Grow Grow 메소드를 실행하지 않음"); System.out.println ( "5. List Grow 0 Times"); } private static void Six () {system.out.println ( "BufferedReader의 생성자 만 리더 인스턴스 만 허용"); System.out.println ( "6. New BufferedReader (new FileInputStream (/"a.dat/"); 잘못되었습니다"); } private static void seven () {try {if (true) {strach new ioException (); }} catch (filenotfoundException e) {System.out.print ( "FilenotFoundException!"); } catch (ioException e) {System.out.print ( "ioException!"); } catch (예외 e) {System.out.print ( "Exception!"); } system.out.println ( "/n7. ioexception!"); } private static void 8 () {system.out.println ( "String s; system.out.println (s); 오류 : 변수 s가 초기화되지 않았을 수 있습니다. -XLINT를 사용하여/nrecompile : 자세한 내용은 확인되지 않았습니다."); System.out.println ( "8. 由于 String s 没有初始化, 代码不能编译通过"); } private static void 9 () {System.out.println ( "5"+2); System.out.println ( "9. 52"); } private static void ten () {int i = 2; int result = 0; 스위치 (i) {사례 1 : 결과 = 결과 + i; 사례 2 : 결과 = 결과 + i * 2; 사례 3 : 결과 = 결과 + i * 3; } system.out.println ( "result ="+result); System.out.println ( "10. 10"); } private static class null {public static void hello () {system.out.println ( "hello"); } public static void main (String [] args) {((null) null) .hello (); null _null = (null) null; _null.hello (); }} private static class stringexample1 {string str = new String ( "good"); char [] ch = { 'a', 'b', 'c'}; public void Change (String str, char [] ch) {str = "test ok"; ch [0] = 'g'; } public static void main (String [] args) {StringExample1 ex = new StringExample1 (); ex.change (예 : Ex.Ch); System.out.print (ex.str+"및"); System.out.print (ex.ch); System.out.println (); }} private static class stringexample2 {public static void 변경 (문자열 str) {str = "환영"; } public static void main (String [] args) {String str = "1234"; 변경 (str); System.out.println (str); }} private static class forloop {static boolean foo (char c) {System.out.print (c); 진실을 반환하십시오. } public static void main (String [] args) {int i = 0; for (foo ( 'a'); foo ( 'b') && (i <2); foo ( 'c')) {i ++; 음식'); } system.out.println (); }} private static class helloa {public helloa () {system.out.println ( "helloa"); } {system.out.println ( "나는 클래스"); } static {system.out.println ( "static a"); }} private static class hellob 확장 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 ( "메인 시작"); 새로운 hellob (); 새로운 hellob (); System.out.println ( "메인 엔드"); }} public static void main (String [] args) {one (); 둘(); 삼(); 4 (); 다섯(); 육(); 7 (); 여덟(); 아홉(); 열(); null.main (null); StringExample1.main (null); StringExample.main (null); forloop.main (null); hellob.main (null); }}以上就是本文的全部内容 以上就是本文的全部内容, 希望对大家的学习有所帮助, 也希望大家多多支持武林网。