Interview Questions of a Company

Source: Internet
Author: User
1. The output result of the following program is # include <iostream. h> void main () {char * A [] = {"hello", "",
"World "};
Char ** Pa =;
Pa ++;
Cout <* pa
<Endl;} A. The world B.
C. Ello D ellotheworld Answer B 2. The post-order traversal sequence of the known binary tree is bfegcda, and the middle-order traversal sequence is
Badefcg, whose pre-order traversal sequence is a abcdefg B abdcefg C
Adbcfeg D abecdfg answer: the root of descending order a, the left subtree of Middle Order B, and the right subtree of A is the root of Middle Order D.
There is no left subtree in sequence D. The root of the right subtree in descending order D is C, and the left and right subtree in descending order C is EF and G, respectively, from the back-order E is the root of the Left subtree of C, from the middle-order F is the right subtree of E, AB d c e g f, and the pre-order sequence is abdcefg. Answer B 3. stack and queue share the following features: A is both advanced and B is both backward-in-first-out. C is only allowed to be inserted and deleted at the endpoint. d
No common answer C 4. The running result of the following program is: # include <iostream. h> void main () {int A, X;
For (A = 0, x = 0;
<= 1 &&! X ++; A ++)
{
A ++;
}
Cout <
<X <Endl;} A 21 B 22 C 32 d
41 answer a 5. which of the following options is incorrect? A for (int A = 1; A <= 10; A ++); B INT A = 1; do {A ++ ;} while (A <= 10) C. int A = 1; while (A <= 10) {A ++;} D. for (int A = 1; A <= 10; A ++) A ++; The answer to this Ms question is D, but after "passing by ^", the user suggested that it should be B, while there is no ";"

6. Which of the following arrays is correctly initialized is a char STR [2] = {"A", "B "};
B.
Char STR [2] [3] = {"A", "B"}; C. char STR [2] [3] ={{ 'A', 'B '},
{'E', 'D'}, {'E', 'F '}};
D. char STR [] = {"A", "B"}; Answer B is difficult. "A", "B" is a string, which is equivalent to a one-dimensional character array 7. which of the following statements is true: the A inline function inserts the target code of the function into each place where the function is called. The B inline function inserts the target code of the function into each place where the function is called during compilation. class C inline functions must be defined in Class D inline functions must be defined out of class by the keyword inline: B 8. which of the following statements about static data members is true: A static data member can initialize B in the class. static member functions cannot be called by class objects. C. static member functions cannot be operated by private controllers. D. static member functions can be directly called by class names. answer: d 9. in the following operators,. * B.> = C.: D.
Delete answer: 6 operators that cannot be overloaded in C and C ++ :::,.,.*,? :
, Sizeof, typeid 10. the following description about polymorphism, the error is that the polymorphism of a C ++ language is divided into the polymorphism at compilation and the polymorphism at runtime B compilation. The polymorphism at C Runtime can be implemented through function overload through templates and virtual functions. the mechanism for implementing the run-time polymorphism of D is called dynamic binding. Answer: C is difficult. The template is polymorphism during compilation, and the virtual function is run as polymorphism 11.
. If the order of the stack entry is E1, E2, E3, E4, E5, the possible order of the stack entry is a) E3, E2, E5, E4, E1 B)
E2, E3, E5, E4, E1 c) E3, E2, E4, E5, E1 d) All of the above are possible answers: D answer: Set push as an inbound stack, pop is the output stack. A: Push (E1) Push (E2) Push (E3) Pop ()
Pop () Push (E4) Push (E5) Pop () B: Push (E1) Push (E2) Pop () Push (E3)
Pop () Push (E4) Push (E5) Pop () C: Push (E1) Push (E2) Push (E3) Pop ()
Pop () Push (E4) Pop () Push (E5) Pop ()

12. which of the following statements about classes and objects is false? A) class is the struct type in C language, and the object is the struct variable B in C language) the relationship between a class and an object is abstract and specific. c) an object is an instance of a class and an object must belong to an existing class D) class is a unified description of several objects with common behaviors. Answer:.

13. which of the following statements about arrays is false? A) in C ++, the array name is the pointer to the first element of the array. B) an array with a length of N, the value range is 0-n-1c) The size of the array must be determined at compilation. d) The array can only be passed to the function through the value parameter and reference parameter methods: the D array transmits parameters through value parameters and address parameters.

14. When referencing a standard library, which of the following statements is true is a) Statement # include
"Stdlib. H" is correct, but it will affect the execution speed of the program. B) Statement # include
<Stdlib. h> is correct, and the program execution speed is faster than # include "stdlib. H". c) Statement # include "stdlib. H" and # include
<Stdlib. h> All are correct, and the execution speed of the program is no different. d) Statement # include "stdlib. H" is incorrect. Answer: B # include
"Stdlib. H" first searches for the directory where the current source file is located and finds the system-defined include directory, # include
<Stdlib. h> directly search

15. Set a, B, c, d, M, and N to int variables, and a = 5, B = 6,
C = 7, D = 8, m = 2, n = 2, after the logical expression (M = A> B) & (n = C> d) operation, value of N: a) 0 B)
1 c) 2 D) 7 answer: Ca> B is false, m = 0, & the first half is not
Run

16. It cannot be used as the basis for calling the overload function: a) number of parameters
B) parameter type C) Function Type
D) function name answer: C17. the output result of the following program is
:


# Include <
Iostream. h>
Int func (int n)
{

  
If

N <1) return 1; else return N + func (n-1); Return 0;
}
Void main ()
{Cout <func (5) <Endl;} A) 0
B) 10 C) 15 d) 16 answer: d

18.
When creating a derived class Object
, 3
Constructor types are:
A (
Constructors of the base class
)
,
B (
Constructor of a member object
)
,
C (
Constructor of a derived class
)
This
3
Type of constructor is called in the order
:

A) ABC

  
B) acbc) cab
D) CBA answer: the test procedure is as follows: # include
<Iostream>
Using namespace STD; Class cbase
{
Public:
Cbase ()
{
Cout
<"Cbase" <Endl;
}
}; Class
Cmember
{
Public:
Cmember ()
{
Cout <"cmember"
<Endl;
}
}; Class
Ccreate: Public cbase
{
PRIVATE:
Cmember omember; public: ccreate ()
{
Cout
<"Ccreate" <Endl;
}
};

Int main ()
{
Ccreate ocreate; return 0;} output: cbasecmemberccreate

19.
If an operator is reloaded by a friend function, the parameter table does not
If any parameter is specified, the operator is a) unary operation.
Operator B) binary operator C) option A) and option B)
Can d) overload error answer: D youyuan function to overload the unary operator must have a parameter, the heavy binary operator must have two parameters

20. There are the following sections: # define f (x, y) (x) --; (y) ++
(X) * (y );... Int I, A = 3, B = 4; for (I = 0; I <5; I ++) f (a, B) printf ("% d, % d ", a, B); the output result is: () A) 3,
4 B) 3, 5C)-2, 5
D)-2, 9 answer: C this question is more difficult: note that f (a, B) does not have ";" the macro should be: for (I = 0; I <5; I ++) x --; y ++;
X * Y; (21) the number of times the for loop body is executed for (int I (10), J (1); I = J = 0;
I ++, j --)
Cout <"execute" <Endl; A) 0 B) 1
C) infinite d) None of the above answers: A judgment condition I = J = 0 value is zero false value (22) the output result of the program below is char * P1 = "123 ", * P2 = "ABC ",
STR [50] = "XYZ ";
Strcpy (STR + 2, strcat (P1, P2 ));
Printf ("% s
", STR); A) xyz123abc B)
Z123abc c) xy123abc d) Error answer: D strcat (char * P1, char * P2)
To connect two strings, the length of P1 must be long enough to accommodate * P1. The execution result of the function below * P2 (23) is output: Char STR [] = "Xunlei ";
Char * P =
STR;
Int n = 10;
Printf ("% d, % d, % d
", Sizeof (STR), sizeof (P), sizeof (n); a) 4, 4, 4 B) 7, 4, 4 C) 6,
4, 4 d) 6, 6, 4 answer: the B pointer occupies four bytes, and the string ends with (24). The execution result of the following function is output: void func (char para [0, 100])
{
Void
* P = malloc (100 );
Printf ("% d, % d
", Sizeof (para), sizeof (p ));
} A) 4, 4 B) 100, 4 C)
4,100 d) 100,100 answer: What a passes to the function is the pointer to the character array (25) What can be searched by the binary method is a) ordered linear table stored in sequence B) Linear Linked List C) binary Linked List D)
Ordered Linear Linked List answer: a binary search must be ordered and stored in sequence. Otherwise, there is no way to fold the half (26) If a Complete Binary Tree has 698 nodes, the number of leaf nodes of the binary tree is:) 349 B) 350 C) 255 d) 351 answer: A any binary tree has N0 leaf nodes and N2 leaf nodes with 2 degrees, then N0 = n2 + 1 is defined by a Complete Binary Tree and 698 of the total number of nodes, the tree must have a unique node with a degree of 1, that is
The last leaf node's parent has: n0-1 + N0 + 1 = 698, N0 = 349 (27) If there is a description: int * P1, * P2, M = 5,
N; which of the following statements is correct? A) P1 = & M; P2 = & P1 B) p1
= & M; P2 = & N; * P1 = * P2c) P1 = & M; * P1 = * P2; d) P1 =
& M; * P2 = * P1 answer: Class B pointer variable needs to be initialized (28)
The function of the following program is to represent 316 as the sum of two Addons, so that the two Addons can be divided by 13 and 11, respectively, the options to be entered in the dash are # include <iostream> int main () {int I = 0, J, K;
Do
{
I ++;
K
= 316-13 * I;} while (____);
J = K/11; cout <"316 = 13 *" <I
<"+ 11 *" <j;} A) K/11 B) K % 11 c) K/11 = 0
D) K % 11 = 0 answer: B (29) the following functions are () int func (btnode * t) {int n = 0; if (t = NULL) return 0; else if (t-> lchild! = NULL |
T-> rchild! = NULL) n = 1; Return (func (t-> lchild) +
Func (t-> rchild) + n);} A) calculate the number of all leaf nodes B) calculate the number of all nodes C) calculate the number of all branch nodes d) None of the above answers: c For the branch node n = 1, for the leaf node n = 0 (30), which of the following is the correct definition of Enumeration type names? A) Enum A = {One, Two, Three }; b)
Enum A {one = 9, tow =-1, three}; c) Enum A = {"one", "two", "three "};
D) Enum A {"one", "two", "three"}; answer: B

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.