Java homework and exercises after Class 1

Source: Internet
Author: User

14. What is the use of the main () method? What are the features? A: The main () method is the Java application entry function, where the program starts execution. features: (1) the method name is followed by a pair of parentheses, which is a quick prompt for finding the Java method; a pair of curly braces after the parentheses are the boundary operators that constitute the statement code segment of the method; (2) The method main () is fixed to public and static modifiers. in addition, void defines the return type of the method, indicating that the main () method has no return value. (3) The main function is usually static, and the main function is actually a method of the class, for example, if a class is test, the main of the class is test. main (string [] ARGs). It is well known that if a method is not static, the class should be instantiated first, for example, test T = new test ();
Then you can call test. Main ();

This is unrealistic for the main function that runs a program. For example, the main function is defined as static so that test. Main () can be directly called. (4) The main () method of Java requires a single parameter of the string [] type. The string [] type is an array of the string list; string [] ARGs is a form parameter of the main function. It can be used to obtain parameters input by the command line user. (5) The main function is the entry of the program. To ensure the security of the program running, both C and Java allow only one entry in one project. A project has more than one class, and each class can have a main method, but the real program entrance can only have one 20. A: The output result of the program is: our hearts will always be young! Long live friendship! 21. incorrect identifiers include: Java. AWT. graphics cannot use ". "As the identifier; X-ray cannot use"-"as the identifier; 2beornot2be cannot start with a number; Mary 'slost cannot use" '"As the identifier; 22. what is the length of the text string "1/T2/T3? A: Its length is 7.

 

Related Article

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.