试题如下 :
参考答案 :
Импорт java.io.filenotFoundException; импорт java.io.ioexception; import java.util.arraylist; import java.util.concurrent.executorservice; import java.util.concurrent.executors;/*** Создан YSC 26/16. */public class wearw {private static void One () {string str1 = "hello"; String str2 = "he"+new String ("llo"); System.err.println (str1 == str2); System.out.println ("1. false"); } private static void two () {int i = integer.max_value; System.err.println ((i+1) <i); System.out.println ("2. 存在一个 I, 使得 (i+1) <i"); } private static void three () {System.err.println ("gc не поток Java, это нативный поток"); Thread.getAllStackTraces (). KeySet (). Foreach (Thread -> System.out.println (thread.getName ()+" ->"+think.isdaemon ()+""+thread.getPriority ())); System.out.println ("3. GC 线程是 Daemon 线程"); } Частный статический летучий int count = 0; private static void four () {rececusterservice executorservice = executors.newcachedthreadpool (); for (int j = 0; j <10; j ++) {rececusterservice.submit (()-> {for (int i = 0; i <100000000; i ++) {count ++;}}); } System.out.println ("count должен быть:" +10000000+ ", фактическое be:"+count); System.out.println ("4. volatile 不能保证线程安全"); } private static void five () {arraylist <Integer> list = new ArrayList <> (20); list.add (1); System.out.println («Код отладки, не выполнять метод выращивания»); System.out.println ("5. Список выращивания в 0 раз"); } 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) {throw new ioException (); }} catch (filenotFoundException e) {System.out.print ("filenotFoundException!"); } catch (ioException e) {System.out.print ("ioException!"); } catch (Exception e) {System.out.print ("Exception!"); } System.out.println ("/n7. Ioexception!"); } private static void enewer () {System.out.println ("string s; system.out.println (s); ошибка: переменная s, возможно, не была инициализирована/nrecompile с -xlint: не задано подробно."); 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 result = 0; Switch (i) {case 1: result = result + i; Случай 2: Результат = Результат + I * 2; Случай 3: Результат = Результат + I * 3; } System.out.println ("result ="+result); System.out.println ("10. 10"); } частный статический класс 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 изменение (String str, char [] ch) {str = "test 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+"и"); System.out.print (ex.Ch); System.out.println (); }} частный статический класс stringExample2 {public static void -изменение (String str) {str = "Welcome"; } public static void main (string [] args) {string str = "1234"; изменение (str); System.out.println (str); }} частный статический класс 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 (); }} частный статический класс helloa {public helloa () {System.out.println ("helloa"); } {System.out.println ("Я класс"); } static {System.out.println ("static a"); }} частный статический класс Hellob Extens Helloa {public hellob () {System.out.println ("Hellob"); } {System.out.println ("It B Class"); } static {System.out.println ("static b"); } public static void main (string [] args) {System.out.println ("Main Start"); новый Hellob (); новый Hellob (); System.out.println ("Основной конец"); }} public static void main (string [] args) {one (); два(); три(); четыре (); пять(); шесть(); Семь(); восемь(); девять(); десять(); Null.main (null); StringExample1.main (null); StringExample2.main (null); Forloop.main (null); Hellob.main (null); }}以上就是本文的全部内容 , 希望对大家的学习有所帮助 也希望大家多多支持武林网。