Java application question and answer

xiaoxiao2021-03-06  82

Q: In Java, what is Local Variable, Member Variable, Instance Variable? What is their different? A: Local variable is a local variable, which is defined in a method or a statement block. When the process or the statement is completed, the local variable variable is released immediately. Instance variable is corresponding to Class Variable. Simply said that instance variable is no need Static modification, each instance creates a new instance variable; Class Variable is modified with static, which is not created with the creation of the class instance. All classes of instances share a copy of the Class Variable. As for Member Variable, it is inaccurate. My understanding is Instance Variable Class Variable. In the language specification, there is no MEMBER VARIABLE. Q: What conditions must be satisfied? A: 1. The method name is the same; 2. The return type is the same; 3. The parameters are exactly the same, including the type, number of parameters, number, arrangement order. Q: What are the Java naming conventions? A: 1. Use a full descriptor to accurately describe variables, fields, or classes. For example, the name used can be FirstName, GrandTotal, or Corporate Customer. Although the names such as X1, Y1 or Fn are shorter, they do not provide any information to point out the content they represent. This is difficult to understand, maintenance, and enhancement of code. 2. Use the terminology applicable to the field. If your user calls their customers as customers, this class is used to use the term Customer instead of the client. Many developers have made such a mistake: when there is more appropriate terminology in the industry or field, they still think, ready to create general terms for some concepts. 3. Smartly use abbreviations. This means that you should maintain a list of standard short formats (abbreviations), which should be wise to select them and remain consistency during use. For example, if you want to use a short format of a word Arithmetic, select one of Ar, ARI, or Art, record the selected abbreviation (which is not important), and only use this one. 4. Use the uppercase mixing to enhance the readability of the name. Usually should usually use lowercase letters, but write the first alphabet of the class name and interface name to a capital, write all the first letters of all non-starting words to uppercase. 5. Copularize the first letter of the standard first letters. Names often contain standard abbreviations, such as SQL represents "Standard Query Language". SqlDatabase, such as indicating attributes, or the name of SqlDatabase, such as the class, is more convenient to read than SqlDatabase and SqlDatabase. 6. Avoid long name (the maximum 15 characters is relatively appropriate). Although the class name AllimplementTed IterfaceSandSubclass may be a better class name (of course, some exaggeration in this example), but this name is obviously too long, you should rename it as a shorter name. 7. Avoid names are too similar or different from cases in case. The variable name MyObject and MyObjects should not be used at the same time, nor should I use MYORDATABASE and anoradatabase.

转载请注明原文地址:https://www.9cbs.com/read-108099.html

New Post(0)