Java written test question Bank (04 issue) __java

Source: Internet
Author: User
Tags object serialization
Java Written test Bank (04 issue)

1, which narration about the thread is right ()

A, once a thread is created, it starts running immediately.

B, use the Start () method to make a thread available to run, but it does not necessarily start running immediately.

C, when a thread stops running because of preemptive mechanism, it is placed in front of a running queue.

D, a thread may stop and enter the ready state for different reasons.


Answer: BCD

In a preemptive threading model, the operating system can interrupt threads at any time. It is usually interrupted after it has been in operation for a period of time (called a time slice). The result is that no thread can unfairly occupy the processor for a long time.


2, which keyword can add a mutex to an object ()

A,serialize

B,synchronized

C,transient

D,static


Answer: B
A is the object serialization, C is the keyword transient decorated properties will not be serialized, D is static


3, the following argument about thread precedence, the correct one is ()
A, the priority of the thread cannot be changed
B, the priority of the thread is set when the thread is created
C, can be set at any time after the thread is created
D, B and C


Answer: C

The precedence of a thread in the Java language is represented by an integer between Min_priority and max_priority. You can modify the priority of a thread any time after the thread is created.


4, in order to make the module as independent as possible, requirements ()
A The degree of cohesion of the module should be as high as possible, and the degree of coupling should be as strong
B The degree of cohesion of the module should be as high as possible, and the coupling degree should be weak.
C Module's cohesion should be as low as possible, and the coupling degree should be as weak as possible.
D The module's cohesion should be as low as possible, and the degree of coupling should be as strong as possible


Answer: B

The quality of system design is mainly reflected in the independence of the module. There are two main criteria for evaluating the independence of modules: one is the coupling between modules, which indicates the degree of independence of two modules, and the other is the relationship between the modules is close, called cohesion. As a general rule, the coupling between modules is as weak as possible, that is, the module is as independent as possible and requires a high degree of internal cohesion of the module.


5, the following is true for the description of the linear list ()
A The storage space is not necessarily contiguous, and the order in which the elements are stored is arbitrary
B The storage space is not necessarily contiguous, and the previous element must be stored in front of the back element
C The storage space must be contiguous, and the front element must be stored in front of the back-component element
D The storage space must be contiguous, and the storage order of each element is arbitrary


Answer: A

In the chain-type storage structure, storage data structure storage space can be discontinuous, the storage order of each data node and the logical relationship between data elements can be inconsistent, and the logical relationship between data elements is determined by the pointer field.


6, the error in the following narrative is ()

A. A linear table is a finite sequence consisting of n elements

B. A linear table is a linear structure

C. All nodes of a linear table have and only one front and rear parts

D. A linear table can be an empty table


Answer: C

A linear table is a linear structure composed of n (n≥0) elements, so a linear table can be an empty table. But in a linear table, the first node has no precursors, the last node has no successor, and the other nodes have only one predecessor and successor, so option C is wrong.


7, known a binary tree before the sequence traversal and the middle sequence traversal is ABDEGCFH and DBGEACHF respectively, then the two-fork tree's sequential traversal is ()

A.gedhfbca

B.dgebhfca

C.abcdefgh

D.acbfedhg


Answer: B

The traversal of the binary tree has 3 kinds: The preface, the preface and the sequence.

First Order: first access to root node, left node, right node

In order: first access to the left node, root node, right node

After: first access to the left node, right node, root node

According to the results of the sequence traversal and the sequence traversal, the structure of the binary tree can be obtained, and then the sequential traversal is carried out.


8, in an object-oriented approach, inheritance refers to ()
A. Similarity properties of a group of objects
B. The nature of an object with another object
C. The common nature of the objects
D. Mechanisms for sharing properties and operations between classes


Answer: D
Inheritance: In programming, inheritance refers to a mechanism by which subclasses automatically enjoy the properties and methods of the parent class, and can add new properties and methods. It is an important means to realize code sharing, it can make software more open and extensible, which is an effective method of information organization and classification, and also one of the main advantages of object-oriented.

Inheritance is divided into single and multiple inheritance, which means that subclasses can inherit only the properties and operations of a parent class, and multiple inheritance is a subclass that inherits the properties and operations of multiple parent classes.

Extensions: Java is a single inheritance language, and C + + is a multiple inheritance language.


9, the common denominator of stacks and queues is ()
A. It's all advanced first out
B. It's all advanced and out.
C. Only allow inserting and deleting elements at endpoints
D. No common features


Answer: C
Stacks are operations that allow inserts and deletes only at one end of a table, and queues allow insertions at the end of a table and deletions on the other end.


10, the following about modifiers mixed with the argument that the error is ()
A.abstract cannot modify the same class as final
Private members are not allowed in the B.abstract class
The C.abstract method must be in the abstract class
The D.static method can handle non static data


Answer: D

         static methods belong to the class, and the normal method belongs to the object.
         A static method that belongs to a class can be accessed when the object does not exist, and the normal method must first be new to access the object. When we access the call to a static method (using the class name. static method Name) There is no object creation at this time, so the normal method is inaccessible. To avoid this error, Java does not allow access to non-static methods in static methods.

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.