========================================================== ====
========
* **************** Chapter 10 10-06
********************
Note: written in accordance with Java specificationsProgramCodeIf you think the program is wrong
Error. Please point out and explain the cause of the program error.
1. Write Program Results
Class demo {
Public static void func () // throws
Exception
{
Try {
Throw new exception ();
} Finally {
Syso ("B ");
}
}
Public static void main (string [] ARGs ){
Try {
Func ();
Syso ("");
} Catch (exception e ){
Syso ("C ");
}
Syso ("D ");
}
}
Compilation failed;
If this exception is declared in the func method, the result is: B c d
========================================================== ====
========
2. Write Program Results
Class test {
Test (){
Syso ("test ");
}
}
Class demo extends test {
Demo (){
// Super ();
Syso ("Demo ");
}
Public static void main (string []
ARGs ){
New demo ();
New Test ();
}
}
Result:
Test
Demo
Test
This section describes how to instantiate a subclass.
========================================================== ====
======
3. Write Program Results
Interface {}
Class B implements
{
Public String func (){
Return "func ";
}
}
Class demo {
Public static void main (string []
ARGs ){
A A = new B ();
Syso (A. func ());
}
}
Result:
Compilation failed
Because the interface does not define func ()
========================================================== ====
========
Package)
* Classification Management of class files
* Provides a multi-layer namespace for the class
* The first line written in the program file
* The full name of the class name is the package name. Class Name
* A package is also an encapsulation form.
Automatic dos package generation
Javac-D (specify the directory in which this package is stored) space. Space
Xxx. Java
Java pack. xxx
Jar package
* Java compressed package
* Convenient Carrying of projects
* For ease of use, you only need to set the jar path in classpath.
Path
* The database driver and SSH framework are reflected in jar packages.
.
DoS
Enter: jar
Jar-cf xx. jar package name 1 package name 2> path (> put the DoS
In a TXT file)