System.out.println(Math.floor(-4.7)); //-5.0 System.out.println(Math.round(-4.7)); //-5 System.out.println(Math.ceil(-4.7)); //-4.0 package jb; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; /** * What will be output if you try to compile * and run the following code, but there is * no file called Hello.txt in the current * directory?. * */ public class Test1 { public static void main(String argv[]) { Test1 m = new Test1(); System.out.println(m.amethod()); } public int amethod() { try { FileInputStream dis = new FileInputStream("Hello.txt"); } catch (FileNotFoundException fne) { System.out.println("FileNotFoundException"); return -1; } catch (IOException ioe) { System.out.println("IOException"); } finally { System.out.println("finally"); } return 0; } } /** * print: FileNotFoundException finally -1 */ package jb; /** * What will happen if you attempt to compile and run the following code? */ class Base { } class Sub extends Base { } public class Test1 { public static void main(String argv[]) { Base b = new Base(); Sub s = (Sub) b; //pass compile but Runtime Exception } } //byte变量的范围是-128~127 byte b = 128; //编译错误