Java from cainiao to proficient (8)

Source: Internet
Author: User

========================================================== ====

========
* **************** 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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.