Object-oriented (exception Overview), object-oriented (Overview)
/**
* Created by rabbit on 2014-08-05.
* Exception: the program is abnormal during running.
* Exception occurs. The problem is also a specific thing in real life.
* It is described in the form of java classes and encapsulated into objects. Actually
* Java describes the object after the exception.
*
* One type of problem is serious, and the other is non-serious.
*
* For serious cases, java uses the Error class to describe
* Generally, no specific code is written to handle errors.
*
* For non-serious cases, java uses the Exception class to describe
* You can use targeted methods to handle exceptions.
*
* Both Error and Exception have some common content.
* For example, abnormal information and causes
*
* Throwable
* | -- Error
* | -- Exception
*/
Class Demo3
{
Int div (int a, int B)
{
Return a/B;
}
}
Public class ExceptionDemo {
Public static void main (String [] args)
{
Demo3 d = new Demo3 ();
Int x = d. div (4, 0 );
System. out. println ("x" + x );
System. out. println ("over ");
}
}
/*
* Running result
*
* Exception in thread "main" java. lang. ArithmeticException:/by zero
At Demo3.div (ExceptionDemo. java: 8)
At ExceptionDemo. main (ExceptionDemo. java: 15)
At sun. reflect. NativeMethodAccessorImpl. invoke0 (Native Method)
At sun. reflect. NativeMethodAccessorImpl. invoke (NativeMethodAccessorImpl. java: 57)
At sun. reflect. DelegatingMethodAccessorImpl. invoke (DelegatingMethodAccessorImpl. java: 43)
At java. lang. reflect. Method. invoke (Method. java: 601)
At com.intellij.rt.exe cution. application. AppMain. main (AppMain. java: 134)
*
**/
Which of the following statements about object concepts in Object-Oriented Programming is false ()
3
The class should be the encapsulation body of the state and operation.
Who can explain how to handle exceptions in java object-oriented code?
Try {
} Catch (Exception e ){
} Finally {
}