java-2016-10-04

Source: Internet
Author: User
Tags instance method

1. The following is correct (a)

A. Formal parameters can be considered as local variable

B. Formal parameters can be modified by all field modifiers

C. Formal parameters are parameters that are actually passed when the method is called.

D. Form parameters may not be objects

Note:

A: Formal parameters can be considered as local variable. A formal parameter cannot leave a method like a local variable. Only works within methods, and is only used in methods, and is not visible outside the method. B: For formal arguments you can only use the final modifier, and any other modifier will cause a compiler error. However, with this modifier there is also a certain limitation, that is, the method can not make any changes to the parameters. In general, however, the formal parameters of a method do not have to be final decorated.  Only in exceptional cases, that is: the method inner class. Inner class within a method if the parameter or local variable of this method is used, the parameter or local variable should be final. C: The value of the formal parameter is changed by the caller at the time of invocation, and the argument changes the value of the parameter with its own value (pointers, references are in this column), that is, the actual argument is passed. D: The parameter list of the method specifies what information to pass to the method, using the form of the object. Therefore, you must specify the type and name of each passed object in the argument list. Like anything in Java that passes an object, it is actually a reference, and the type of the reference must be the correct

2.Which keyword can protect a class in a package from accessibility to the classes outside the package? D

A.private
b.protected
C.final
D.Don ' t use any keyword @ all (make it default)?
Note:

If a class is declared as protected, its subclasses can access it, and if it and the subclass are not in a package, the subclass can still access the class, so choose default here, that is, nothing is written

3.

Which of the following exceptions is a check-type exception that needs to be declared when writing a program? The correct answer: C your answer: B(Error)
NullPointerException
ClassCastException
FileNotFoundException
Indexoutofboundsexception

In general, Java exceptions (including exception and error) are categorized as checked exceptions and non-checked exceptions (unchecked exceptions).
can check exceptions (compiler requirements must be disposed of exceptions): the correct program in operation, it is easy to appear, reasonable tolerance of abnormal conditions. Although the abnormal condition can be checked, it can be predicted to some extent, and in the event of such abnormal situation, it must be handled in some way.

In addition to RuntimeException and its subclasses, other exception classes and their subclasses belong to the exception-checking. This exception is characterized by the Java compiler checking it, that is, when such an exception can occur in a program, either by capturing it with a try-catch statement or by declaring it with a throws clause, or the compilation will not pass.

Exception not checked (compiler does not require forced disposition of exceptions): Includes run-time exceptions (RuntimeException with its subclasses) and errors (error).

4.

The following statement wrongly has () the correct answer: A c D your answer: C D(Error)
This is used in class methods to invoke class methods of this class
Calling the class method of this class in a class method can be called directly
Only class methods in this class can be called in a class method
An instance method must never be called in a class method
First: The member method is also called the instance method static method is also called the class method second: A, the static method does not have this pointer C, can be called by the class name Class::fun ();d, is too absolute, in the class to request a class object or parameter passed an object or pointer can be called; 5. In the Java language, which of the following questions about character set encoding (Character set encoding) and internationalization (i18n) is correct? Correct answer: C D your answer: A B(Error)
Each Chinese character occupies 2 bytes, and each English character occupies 1 bytes
Assuming that the characters in the database are encoded in GBK, the Web page that displays the database data must also be GBK encoded.
Java type char, the following UTF-16 Big endian the way to save a character.
The most common means to achieve international application is to use the ResourceBundle class
Note:
It's really not going to come out. To clarify some facts many people put the Unicode encoding on the mouth, in fact, we encountered in real-life encoding is basically Unicode because Unicode is compatible with most older versions of the encoding specifications such as   The Asciiunicode code defines the number of characters in the world that are almost all of them (that is, the long-looking symbol you see), which means that Unicode sends an ID card for each character, This ID has a unique set of numeric IDs that determine the uniqueness of this character in this chaotic world. Unicode gives this serial number ID a name called [Code Point] and many people say that the encoding is actually wanted to express [Unicode conversion format] (that is, Utf,unicode transformation Formats) do not feel the light suddenly enlightened? Yes, that's what we saw. The utf-8/utf-16/utf-32 prefix source this [Unicode conversion format] exists to solve the binary representation of [code Point] in the computer, after all, our in-machine representation involves storage bit width, compatible with the old encoding format, A code point is a rare character with too large a value [code point] The conversion format of the binary string obtained by the map is called the [code unit]. That is, if there is a UTF code point binary that has n bytes and its code element is 8 bits (1 byte), then it has a code element N. Each UTF's code element is different, and its width is written as a distinction in the UTF suffix-this is the origin of utf-8/utf-16/utf-32. The code element of the UTF-8 is 8 bits, and the UTF-16 is 16 bits. Most programming languages use a 16-bit code element as an in-machine representation. This is why we call in various languages to get the number of character in a string when there is so much confusion. The fact that we call these methods is not the number of characters, but the number of code elements! Once we have a code point in the string that is outside the base plane, you will need more code to represent it, and this time there will be a common confusion in testing-why is there more characters to return than the actual number of characters? So pay special attention to the problem when you actually write the code. Different formats can be used to get binary strings in different format, but the [code point] they represent will always be the same as if you change your ID card but the identity card number is unchanged. Because people mistakenly put [conversion format] also known as [coding], so that today Unicode/utf silly points and use the confusion of the wording of the tragic situation. unicode  coding   Development to today   expanded to  21  bit (from  u+0000  to  U+10FFFF ). This is important:  Unicode is not - bits of code,It's a 21-bit. These 21 bits provide 1,114,112 code points, of which only about 10% are in use, so there is considerable room for expansion. The coded space is divided into 17 plane(plane), each plane has 65,536 characters (just padding 2 bytes, 16 bits). Plane number No. 0 is called "Basic Multilingual Plane" ( BMP, Basic Multilingual Plane ), covering almost all the characters you can encounter, except emoji (emoji is located on the 1th plane –). The other planes are called supplementary planes, mostly empty. Summarize the characteristics of the various coding formats:

UTF-32

One of the most clear UTF is UTF-32: It uses the whole 32 bits on each code point. 32 is greater than 21, so each UTF-32 value can be directly represented by the corresponding code point. Although simple, UTF-32 is almost never used in practice, because each character occupies 4 bytes and is too wasted space.

UTF-16 and the "proxy pair" ( Surrogate Pairs ) Concept of

UTF-16 is much more common, it is defined by code units with 16 fixed-length bits. The UTF-16 itself is a variable-length encoding. Each code point in the Basic Multilingual Plane (BMP) is mapped directly to a single code element. Since BMP contains almost all the common characters, UTF-16 generally only needs to UTF-32 half the space. The code points that are rarely used in other planes are encoded with two 16-bit code elements, which are called surrogate pairs ( surrogate pair ), which together represent a code point.

UTF-8

UTF-8 uses one to four bytes to encode a code point. The code points from 0 to 127 map directly to 1 bytes (this makes UTF-8 and ASCII exactly the same for text that contains only this range of characters). The next 1,920 code points are mapped to 2 bytes, and all the remaining code points in the BMP require 3 bytes. Code points in other planes of Unicode require 4 bytes. UTF-8 is based on a 8-bit code, so it doesn't need to be concerned with byte order (although there are still some programs that add an extra BOM to the UTF-8 file).

Efficient use of space (in western languages only), and the need to worry about byte order issues make UTF-8 the best encoding for storing and communicating Unicode text. It is also a file format, network protocol, and web API in factThe standard. The Save code point in our JVM is the conversion format of UTF16, which can be seen from the bit width of char to 16 bits. Since most code points are in the basic plane, using 16 bits can represent almost all characters commonly used characters. This is why many language compilers or runtimes use UTF16. English is also represented in 2 bytes when using UTF16. When we want to use other flat characters, the code element more than 2 bytes, you need to use the proxy for the specific representation in the language, such as ' \u112233 '. When using UTF8, the commonly used alphabet and numeric are in the first 127 bytes, and are efficiently represented by a single byte. Since our Chinese is ranked at 1920 yards, we use 3 bytes to represent it, which consumes more space than the UTF16 conversion format. 6. What's the right thing to say about Java ClassLoader? Correct answer: A B C D your answer: C(Error)
Boot class loader (bootstrap class loader): It is used to load Java's core library, which is implemented by native code.
Extension class loader (Extensions class loader): It is used to load the Java extension library.
System class Loader: It loads Java classes according to the Classpath (CLASSPATH) of the Java application
Tomcat creates a loader for each app that holds the classloader of this webapp. When you need to load a class under WebApp, remove ClassLoader to use
Note:
Bootstrap ClassLoader-Boot (also known as primitive) class loader, which is responsible for loading Java's core classes. Extension ClassLoader-the extension classloader, which is responsible for loading the class pack of the jar in the JRE's extended directory (Java_home/jre/lib/ext or specified by the Java.ext.dirs system properties). System ClassLoader-Systems (also known as applications) ClassLoader, which is responsible for loading-classpath or Java.class.path System Properties from command Java or classpath* when the JVM is started The jar class package and classpath as specified by the System properties

java-2016-10-04

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.