1, Thread.Sleep () will throw checked exception?
Answer: Yes. Checked exception is a required exception and is validated by the compiler. For any method that declares an exception to be thrown, the compiler will force the processing or declaration of the rule. Unchecked exception is exempt from exception, such as RuntimeException. It is a run-time exception. Because such exceptions are usually raised by specific actions, these operations often occur in memory. Thread.Sleep () throws Interruptedexception exception, which belongs to checked exception.
2, Math.floor (-8.5) =?
Answer: (double)-9.0. Math.floor (): Returns a double type that is not greater than the maximum integer of the number. Math.Round (): Returns int, rounded, algorithm Math.floor (x+0.5), representing the original number plus 0.5 down rounding. The result of Math.Round (-11.5) is:-11
3, the following code output is?
public class Testdemo {public static String output = ""; public static void foo (int i) { try{ if (i = = 1) { throw new Exception (); } } catch (Exception e) { output + = "2"; return; } finally{ Output + = "3"; } Output + = "4"; } public static void Main (string[] args) { foo (0); Foo (1); SYSTEM.OUT.PRINTLN (output); } }
Answer: 3423. After the Try-catch execution is finished, the program continues to execute downward. throw new Exception (), an exception has occurred, and the program finishes executing the finally block.
4, the results of the program output:
public class Hellob extends Helloa {public Hellob () {} { System.out.println ("I ' M B class");} static { System.ou T.println ("Static B"); } public static void Main (string[] args) { new Hellob ();}} Class helloa{Public Helloa () {} { System.out.println ("I ' M A class"),} static { System.out.println ("Static A"); }}
For:
Static Astatic BI ' m A ClassI ' m B class
This topic mainly examines the Java execution order. Parent class static Block--subclass static Block--parent class block--parent class constructor--subclass block--child class constructor
Reference http://java-mzd.iteye.com/blog/838683
5, AWT is based on the local method of C/C + + program, it runs faster; Swing is an AWT-based Java program that runs slower. 6.
Class methods cannot be called with this, and class methods that call this class in a class method can be called directly; class methods of other classes can be called in class methods; instance methods can be called in class methods
The class method is a static method, and this is the property and method that invokes the current object. Therefore, you cannot invoke the class method with this.
The first back of the Java face question