Java Programming specification

Source: Internet
Author: User
Tags arithmetic operators case statement class definition define local file copy logical operators modifiers

Address

First, single choice
1. The following description of the collection class is incorrect
A. Name the attribute containing the set meaning and try to include the meaning of its plural
B. Data in the collection does not need to be freed and the garbage collector is automatically recycled
C. The collection must specify a template type
D. Setting the initialization capacity when using the collection class
2. There is a mistake in the following thread
A. Start a new thread and use Thread.setname ("...") to set the thread name
B. In JDK1.5 or later versions, if string concatenation occurs in a single-threaded environment, use StringBuffer
C. For multi-threaded access variables, methods, must lock protection, to avoid the problems caused by multi-threaded concurrent access
D. When threading is used, use the thread pool in the code framework to avoid creating non-reusable threads, prohibit creating new threads in loops, or cause JVM resources to be exhausted
3. Which of the following is the recommended symmetric cipher algorithm
A. DES
B. AES
C. SHA
D. RSA
4. The following statements are correct
A. Some states in the program are directly represented by numbers, such as the successful return of function execution 1
B. For a representation of a function execution error, a multi-use convention error code is used to identify
C. Use a meaningful static variable or enumeration in place of a numeric program state, such as a successful return of a function execution SUCCESS
D. The number of demons in the program is not scary and requires all developers to try to understand what these numbers mean
5. The following error uses the exception method is
A. Using exception handling in a program or using error return code processing, depending on whether the program structure is beneficial, and exceptions and error codes should not be mixed, it is recommended to use exceptions
B. A method should not throw too many types of exceptions. The throws/exception clause is best not to exceed three exceptions
C. Exception capture try not to direct catch (Exception ex), the exception should be broken down processing
D. Exceptions thrown in the program can be used to describe the type of exception, throw conditions, and do not fill in the detailed description information. Save after catching an exception with exception.tostring () after fetching the details
6. With regard to naming conventions, the following statements are erroneous
A. The attribute name uses the full English description, the first word of the letter is lowercase, the remainder of the first letter uppercase the remaining letters lowercase case of the mixed method. Property name cannot be the same as method name
B. Method name use class meaning complete English description: The first word of the letter using lowercase, the remainder of the first letter uppercase and lowercase of the remaining letters of the case mixed method
C. In the method, the method of accessing attributes adopts setter and getter method, and the action method adopts verb and dynamic object structure.
D. The constant name is described in English with all capitals, the English words are separated by underscores, and the static modifier is used
7. Which of the following scenarios can use the random number generated by the Java.util.Random class
A. Random number generation in the challenge algorithm
B. Random number generation of verification codes
C. Randomly selected routes
D. Web App session identifiers
8. A code that uses Zipinputstream to decompress the compressed file, fill in the appropriate keywords at [1] is
Public Randomaccessfile OpenFile (Java.io.File f) {
[1] java.io.File copy = new Java.io.File (F.getpath ());
Askuserpermission (Copy.getpath ());
// ...
Return (Randomaccessfile) accesscontroller.doprivileged (new Privilegedaction () {
Public Object Run () {
return new Randomaccessfile (copy, Copy.getpath ());
}
});
}
A. Final
B. Static
C. Volatile
D. Private
9. In the Code of Safety programming, the following statement is wrong
A. Verifying the external input
B. Prohibiting untrusted code from terminating the JVM directly
C. Specifying reasonable access rights when creating a file
D. Can throw exceptions when logging
10. If you need to obtain the operating system login user name in the program, you should take the following method to obtain
A. Prompt user for input
B. Obtained by environment variable: system.getenv ("USER")
C. Obtained by JVM attribute: System.getproperty ("User.Name")
D. When starting the program by the program parameters passed in
11. The following statement is correct
A. Try to use the Java 5.0 new loop notation
B. To determine if a variable is equal to null, or a constant, place the variable on the left side of the operator
C. Method parameters cannot exceed 7
D. Comparing two string contents with "= ="
12. In which of the following scenarios, encryption and digital signature mechanisms are not required to ensure data security
A. Serializing the transmission of sensitive data
B. No SSL transmission channel or too expensive
C. Sensitive data needs to persist for long periods of time
D. Inter-component delivery within the same trusting domain
13. In the following JDK API calls, if the use of improper vulnerability to the OS command injection is
A. Java.lang.System.load ()
B. Java.lang.Runtime.exec ()
C. Java.lang.Thread.start ()
D. Java.lang.Process.waitFor ()
14. The following description is incorrect
A. Do not use the same method name as the class name except for the builder
B. Use Equals () to compare the values of two classes
C. Do not use nested assignments, that is, use multiple = in an expression
D. Overloading the Equals () method does not have to overload the Hashcode () method
15. The following non-conforming coding specifications are
A. Databases, IO operations, and so on, objects that need to use close () must be close () in try-catch-finally finally
B. Use int[] index when declaring an array, instead of using int index[]
C. All classes must overload the ToString () method to return content that is meaningful to that class
D. The exception you throw must fill in the detailed description information
16. For the following code fragment, assuming that an instance of Passwordmanager can be accessed by untrusted code and that the ChangePassword () method call is sensitive, the following statements are incorrect.
public class Passwordmanager
{
Public final Object lock = new Object ();

public void ChangePassword () throws FileNotFoundException
{
Synchronized (lock)
{
// . . .
}
}
}
A. The security Manager check should be included in the ChangePassword () method to confirm that the calling code has the Operation permission
B. The visibility of the lock member variable should be declared as private
C. The synchronization block in the ChangePassword () method can be omitted, and the ChangePassword () method is declared directly as a synchronized-modified synchronization method
D. ChangePassword () method should not throw FileNotFoundException exception
17. The best way to protect against SQL injection is to
A. Restricting the length of external inputs
B. Using Stored procedures
C. Using pre-compiled statements--java.sql.preparedstatement
D. Escaping external input
In the Jaas Grant class, it does not contain any of the following
A. Policy
B. authpermission
C. privatecredentialpermission
D. LoginContext
19. The following statement or statements do not conform to the requirements of the layout of the company's programming code is
A. Commas and semicolons are only appended with spaces; Comparison operators, assignment operators "=", "+ =", arithmetic operators "+", "%", logical operators "&&", "&", Bit-field operators "<<", "^" and other binocular operators before and after adding space; "!", "~", "+ +", "--", "&" (address operator) no space before and after the monocular operators
B. If the statement is clear enough, the inside of the brackets (that is, the opening parenthesis and the right parenthesis) do not need a space, and there is no space between the braces, because parentheses are the clearest sign in the Java language.
C. Longer statements, expressions, or parameters (>80 characters) to be divided into multiple lines of writing, long expressions to the lower priority operators to divide the new line, the operator placed in the first line of new lines, the new lines are divided into the appropriate indentation, so that the layout is neat, the statement can be read
D. If, for, does, while and other statement execution statements if there is only one line, do not need to parentheses {}
20. The description of the comment is incorrect
A. Public and Protection methods Note content: A brief description of the method, function details, input parameters, output parameters, return values, exceptions, etc.
B. Methods for overloading a parent class must be @override declared
C. The definition of key variables must be written in comments, branch statements (conditional branches, loop statements, etc.), can be based on the actual situation, you can add comments, or do not add, according to the amount of comments to determine
D. For exceptions thrown with a throw statement inside a method, you must indicate in the comment of the method that the exception that is thrown by the other method being invoked is selected primarily in the comment. For non-runtimeexception, that is, the exception that is thrown by the throws clause declaration, must be indicated in the comment of the method
Second, multi-choice
21. The following class names conform to the company's specifications
A. Ftpdownload_util
B. Debuglog
C. Orderresponse
D. Usermanager
22. Which of the following areas should be added blank lines
A. Between the import statement and the class definition
B. Note between the comments and the irrelevant code above
C. Between comments and commented code
D. After the variable description
23. With regard to local variables, the argument that conforms to the programming specification is
A. Do not define local variables that will not be used, class private properties, class private methods, and method parameters
B. Almost every declaration of a local variable should contain an initialization expression
C. The "nearest principle" for variable definitions
D. Property names can be the same as public method parameters, or they can be the same as local variables
24. The following statements describe the correct
A. The legality check of public method parameters should be the responsibility of the method itself, and each public method must ensure its robustness
B. A validation must be performed after the calling method gets the returned result to ensure that subsequent code does not throw an exception or generate a logic error during the run
C. When accessing elements in an array, list, and other containers, you must first check that the subscript is out of bounds and eliminate the occurrence of subscript out-of-bounds exceptions.
D. For if? else if? (There may be multiple else if ...) This type of conditional judgment, finally must contain an else branch, to avoid the branch omission caused by error, each Switch-case statement must be guaranteed to have the default, avoid branch omission, causing errors
25. The following description of access control symbols, according to the Code of
A. Only functions that are called internally by this class use the private property
B. Inherited classes can use the protected property
C. Externally exposed functions use the public property
D. The member variables of the class are protected decorated as much as possible, and other classes can access and modify the variables through the member methods of the class
26. The following comments about classes and interfaces, the correct argument is
A. Before the class or interface keyword
B. After the Import keyword
C. Comments are mainly a sentence function description and function
D. Class annotations using the "/****/" annotation method
27. The following statements are correct
A. A system or module should uniformly plan the meaning of the exception type and return code
B. Abnormal processing efficiency is lower than the conditional branch
C. Abnormal jump flow is difficult to predict
D. If the exception is not processed after the exception caught by the system's unhealthy operation, the log should be logged
28. With regard to anomalies, the following statements are correct
A. Run-time exceptions are represented by RuntimeException subclasses, without adding throws clauses on method declarations that may throw exceptions
B. Run-time exceptions are represented by subclasses of RuntimeException and must be added with throws clauses on method declarations that may throw exceptions
C. Non-runtime exceptions are inherited from exception and must be added to the throws clause on the method declaration
D. Non-runtime exceptions are inherited from exception and do not need to be added to the throws clause on the method declaration
29. In the following typesetting code, according to the coding specification is
A. if (i>j) Dostart ();
B. Object o = new Object (); Object B = null;
C. class definition {class's Public property definition class's Protection property definition class's private property definition class's public method definition class's protection method definition class's private method definition}
D. Typecounter *= 2;
30. When the loop is nested, the following conditions need to be avoided as much as possible
A. Instantiating an object
B. Try/catch
C. Enable IO
D. Connecting to a database
Three, the judgment question
31. NumberFormatException exception must be handled when converting a string to a number
That's right
Error
32. Do not define two classes for a file (not an internal class)
That's right
Error
The constants defined in interface do not write public, static, final modifiers, methods need to write public modifiers
That's right
Error
34. It should be clearly stipulated that the legality check of the interface method parameters should be the responsibility of the caller of the method or the interface method itself, by default the method caller is responsible for
That's right
Error
35. Before the code is submitted, you need to eliminate the error, alarm, and clear the Findbug
That's right
Error
36. For case statements under the switch statement, the break statement must be preceded by the end of each cases branch
That's right
Error
37. Judgment statement can use "* = = true" To determine the true
That's right
Error
38. Do not use loops to convert a collection to an array, you can use the ToArray () method of the collection
That's right
Error
39. The Serializable class that implements the Serializable interface should be explicitly private static final declaration Serialversionuid
That's right
Error
40. Class properties and class methods can be cross-positioned
That's right
Error

Java Programming specification

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.