CSE2056532 If the user enters: 123 What does the program below output? import java.util.Scanner; import java.util.InputMismatchException; public class Main { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int num = 0; try { num = scnr.nextInt(); System.out.print("Good! "); } catch (InputMismatchException e) { System.out.print("Bad! "); } System.out.print(num); } }单项选择题
A
None of these
B
Good! 123
C
Bad!
D
Bad! 123
E
Good!
F
123
登录即可查看完整答案
我们收录了全球超50000道真实原题与详细解析,现在登录,立即获得答案。
类似问题
What does this method returns? int a, b = 0; try{ try{ a= 24/b; }catch(ArithmeticException ex){ }finally{ a = -1; b = 1; } }finally{ a = 0; } a = 24/b; return a;
Which XXX defines a finally block to close a file? public class FileReadChars { public static void main(String[] args) { FileReader fileReader = null; String fileName; int charRead; charRead = 0; fileName = "file.txt"; try { System.out.println("Opening file " + fileName + "."); fileReader = new FileReader(fileName); System.out.print("Reading character values: "); while (charRead != -1) { charRead = fileReader.read; System.out.print(charRead + " "); } System.out.println(); } catch (IOException excpt) { System.out.println("Caught IOException: " + excpt.getMessage()); } finally { try{ XXX } catch (IOException excpt) { System.out.println("Caught IOException: " + excpt.getMessage()); } } } } ----- fileReader.close(); if (fileReader == null){ fileReader.close(); } if (fileReader != null){ fileReader.close(); } close(fileReader);
Multiple exceptions, and finally Choose the correct statements about the following code snippet. try { aaaaa(); // throws IOException bbbbb(); // throws EOFException } catch (EOFException x) { System.out.println (“EOF Stress: “ + x.getMessage()); } catch (IOException x) { System.out.println (“IO Stress: “ + x.getMessage()); } finally { cleanup(); } whateverComesNext(); 1: With multiple exceptions, at most 1 catch block executes. 2: A finally block always executes, 3: bbbbb() may not get executed if an exception happens in aaaaa() 4: whateverComesNext() may not get executed if an exception happens in aaaaa()
Section A: Read the text and answer the questions. Brutalism is an architectural style, introduced in the 1950s. It uses exposed concrete to create geometric structures with a grey appearance. Concrete buildings are often criticised as cold and ugly, lacking the warmth of stone or the smooth feel of steel. However, concrete, as a building material, has unique characteristics. It is extremely flexible when wet, and is adapted to create interesting shapes. Many urban public buildings, such as universities, have also used concrete as the main material to indicate strength and permanence. Instead of keeping Brutalist buildings, many are being demolished to make space for modern styles. However, this does not acknowledge the cultural history of these buildings, and is not sustainable. Fill in the gap with ONE WORD from the paragraph. 1. Brutalist architecture included exposed concrete, which gave a cold Answer Question 1[input] .
更多留学生实用工具
希望你的学习变得更简单
加入我们,立即解锁 海量真题 与 独家解析,让复习快人一步!