A large Internet integrated service provider in China, published on the morning of October 11, October 14

Source: Internet
Author: User

It's strange that none of them have a logic question. In addition, the question volume is not big, and the difficulty is only a little big. However, some places are buried with mines. Be careful when you do this. Several questions related to blind spots of your own knowledge are recorded. I believe that as I accumulate, I will catch a big fish! Come on! Cainiao ~~

I. multiple choice questions:

1. Evaluate function output

class A{public:int m_a;A():m_a(0){cout << "A" << endl;}};class B : public A{public:int m_a;B():m_a(2){cout << "B" << endl;}};int main(){A * a = new B();cout << sizeof(B) << endl;cout << a->m_a << endl;}

The answer is a B 8 0. Analysis: The subclass inherits the data members of the parent class. In addition, sizeof (A) = 4. When a base class Pointer Points to a subclass object, this pointer can only access the member variables of the parent class.

2. These fields are involved. You need to know. On the TCP layer, there is a flags field, which has the following identifiers: SYN, FIN, ack, Psh, RST, and URG.

The preceding five fields are useful for our daily analysis.

Their meanings are:

SYN indicates establishing a connection, Fin indicates closing the connection, Ack indicates responding, PSH indicates data transmission, and RST indicates resetting the connection.

Among them, Ack may be used together with SYN and fin. For example, SYN and ACK may both be 1, which indicates the response after the connection is established,

If it is only a single SYN, all it means is to establish a connection.

The several handshakes of TCP are represented by such ack.

However, SYN and fin are not 1 at the same time, because the former indicates a connection, while the latter indicates a disconnection.

RST is usually 1 after Fin, indicating that the connection is reset.

Generally, when a fin or RST packet occurs, we think that the client is disconnected from the server. When a SYN and SYN + ACK packet appears, we think the client has established a connection with the server.

When PSH is 1, it usually only appears in packets whose data content is not 0. That is to say, PSH is 1, indicating that the real TCP packet content is transmitted.

Both TCP connection establishment and connection closure are completed in request-response mode.

Concept supplement-TCP three-way handshake:

TCP (Transmission Control Protocol) Transmission Control Protocol

TCP is the transmission control protocol used by the host to control the host layer. It provides reliable connection services and uses three handshakes to establish a connection:

The location code is the TCP flag. There are 6 types of tags: SYN (synchronous established online) ack (acknowledgement confirmation) Psh (push transfer) Fin (finish ended) RST (reset) URG (Urgent urgent) sequence number (sequence number) Acknowledge number (confirmation number)

The first handshake: host a sends a packet with a SYN = 1 and generates a random seq number = 1234567 packet to the server. Host B is known as SYN = 1, and host a requires online connection;

The second handshake: after receiving the request, host B needs to confirm the online information and send ACK number = (SEQ + 1 of host a), SYN = 1, ACK = 1, generates packets with seq = 7654321 at random;

The third handshake: After receiving the handshake, host a checks whether the ACK number is correct, that is, the seq number + 1 sent for the first time, and whether the Ack is 1. If yes, host a will send ACK number = (SEQ + 1 of host B), ACK = 1 again. After host B receives the message, confirm that the seq value is set to ACK = 1, and the connection is established successfully.

After three handshakes are completed, data is transmitted between host a and host B.

3. What is output from the Win32 x86 machine?

union U{    char a;    int b;    double c;};struct A{    char b;    U a;    };int main(){    cout << sizeof(A) << endl;}

The answer is 16. This item is not included in the option. Only 8, 12, and so on. Remember that sizeof (double) = 8.

4. Addressing method included in the instruction: addressing immediately. The immediate number in the immediate addressing is a part of the instruction and is stored in the code segment. The execution does not need to retrieve the data in the data segment. For example, mov ax and 10 h adopt the immediate addressing mode. This command (including the operands ax and 10 h) is compiled into a machine code by the assembler, this command is loaded into the instruction Buffer Queue before execution. During execution, the CPU reads the code of this machine for 10 hours, 10 h can be immediately sent to ax (instead of the number of operations in the register or memory), so it is called immediate addressing, and the instruction execution efficiency is the highest.

5. Comparison of raid0, 1, 2, 5, 10 stability?

(Raid,REdundantARrayINexpensive
DIsks (abbreviation)Hard Disk ArrayThe basic idea is to combine multiple relatively inexpensive hard disks into a hard disk array group, so that the performance can reach or even exceed a hard disk with a high price and huge capacity. The more stable it is, the less unstable it is. Here, raid 10 refers to raid 1 + 0 instead of RAID 10.

6. Which statement is used in HTML to represent the hyperlink.

HTML uses <A> to represent hyperlinks. The English name is anchor.

<A> you can point to any file source: an HTML webpage, an image, or a video file. The usage is as follows:

<A href = "url"> link display text </a>

Click <A> </a> to open a link file. The href attribute indicates the path of the link file.

For example, you can link to the homepage of the blabla.cn site as follows:

<A href = "url"> link display text </a>

7. Use the output of the previous command as the input of the next command. Which command mode is this? A. input redirection; B. Output redirection; C. Pipeline answer: C.

Ii. Fill in blank questions:

1. What are four types of delimiters in C ++? Const_cast, static_cast, reinterpret_cast, dynamic_cast.

The corresponding examples are as follows:

I) const_cast

Char * string_copy (char * s) {return s;} int main () {const char * pc_str = new char; // char * Pc = string_copy (pc_str ); // If pc_str is directly input, the compilation error is char * Pc = string_copy (const_cast <char *> (pc_str); If (pc_str = PC) cout <"hello" <Endl; return 0 ;}

After running, output hello
Ii) static_cast

Int main () {double D = 12; void * P = & D; // cout <* P <Endl; // error: must be a pointer to a complete object type. double * Pd = static_cast <double *> (p); cout <* PD <Endl ;}

OUTPUT 12.

Iii) reinterpret_cast

Int main () {int * IP = new int; char * Pc = reinterpret_cast <char *> (IP); string STR (PC); // string (IP ); // error. The type does not match .}

It can run normally. In the preceding example, you only need to understand the meaning. The example is not good.

Iv) dynamic_cast

class A{public:virtual void print() const{cout <<"A\n";}};class B{public:virtual void print() const {cout<< "B\n";}};class C:public A, public B{public:void print() const {cout << "C\n";}};int main(){A * a = new A;B * b = new B;C * c = new C;a->print(); b->print(); c->print();b = dynamic_cast<B*>(a); if(b)b->print();elsecout << "no B\n";a = c;a->print();b = dynamic_cast<B*>(a);if(b)b->print();elsecout << "no B\n";b = dynamic_cast<B*>(c);if(c)b->print();elsecout << "no B\n";}

After running, output

A
B
C
No B
C
C
C
It is even more powerful in foreign countries.

2. PM is the first address of a piece of available memory. How do I implement it if I want to allocate Class A objects to this memory? PM = new ();

3. Bit-map. Where, place nth bit, char B [Len]; If (n <Len) B [N] |= ?; 1.

Iii. Major issues:

A pair of 54 cards numbered 1-54. Please design an algorithm to randomly disrupt these cards. Perfect sorting looks good. But I haven't understood it yet... A little difficult!

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.