常见英文面试笔试题目.doc
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《常见英文面试笔试题目.doc》由会员分享,可在线阅读,更多相关《常见英文面试笔试题目.doc(14页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、【精品文档】如有侵权,请联系网站删除,仅供学习与交流常见英文面试笔试题目.精品文档.C/C+ Programming interview questions and answers By Satish Shetty, July 14th, 2004What is encapsulation?Containing and hiding information about an object, such as internal data structures and code. Encapsulation isolates the internal complexity of an objects
2、 operation from the rest of the application. For example, a client component asking for net revenue from a business object need not know the datas origin.What is inheritance?Inheritance allows one class to reuse the state and behavior of another class. The derived class inherits the properties and m
3、ethod implementations of the base class and extends it by overriding methods and adding additional properties and methods.What is Polymorphism?Polymorphism allows a client to treat different objects in the same way even if they were created from different classes and exhibit different behaviors.You
4、can use implementation inheritance to achieve polymorphism in languages such as C+ and Java.Base class objects pointer can invoke methods in derived class objects.You can also achieve polymorphism in C+ by function overloading and operator overloading.What is constructor or ctor?Constructor creates
5、an object and initializes it. It also creates vtable for virtual functions. It is different from other methods in a class.What is destructor?Destructor usually deletes any extra resources allocated by the object. What is default constructor?Constructor with no arguments or all the arguments has defa
6、ult values.What is copy constructor?Constructor which initializes the its object member variables ( by shallow copying) with another object of the same class. If you dont implement one in your class then compiler implements one for you.for example:Boo Obj1(10); / calling Boo constructorBoo Obj2(Obj1
7、); / calling boo copy constructorBoo Obj2 = Obj1;/ calling boo copy constructorWhen are copy constructors called? Copy constructors are called in following cases: a) when a function returns an object of that class by valueb) when the object of that class is passed by value as an argument to a functi
8、onc) when you construct an object based on another object of the same classd) When compiler generates a temporary objectWhat is assignment operator? Default assignment operator handles assigning one object to another of the same class. Member to member copy (shallow copy)What are all the implicit me
9、mber functions of the class? Or what are all the functions which compiler implements for us if we dont define one.?default ctorcopy ctorassignment operatordefault destructoraddress operatorWhat is conversion constructor?constructor with a single argument makes that constructor as conversion ctor and
10、 it can be used for type conversion.for example:class Boo public: Boo( int i );Boo BooObject = 10 ; / assigning int 10 Boo objectWhat is conversion operator?class can have a public method for specific data type conversions.for example:class Boo double value; public: Boo(int i ) operator double() ret
11、urn value; ;Boo BooObject;double i = BooObject; / assigning object to variable i of type double. now conversion operator gets called to assign the value.What is diff between malloc()/free() and new/delete?malloc allocates memory for object in heap but doesnt invoke objects constructor to initiallize
12、 the object.new allocates memory and also invokes constructor to initialize the object.malloc() and free() do not support object semantics Does not construct and destruct objects string * ptr = (string *)(malloc (sizeof(string)Are not safe Does not calculate the size of the objects that it construct
13、 Returns a pointer to void int *p = (int *) (malloc(sizeof(int);int *p = new int;Are not extensible new and delete can be overloaded in a class delete first calls the objects termination routine (i.e. its destructor) and then releases the space the object occupied on the heap memory. If an array of
14、objects was created using new, then delete must be told that it is dealing with an array by preceding the name with an empty :-Int_t *my_ints = new Int_t10;delete my_ints;what is the diff between new and operator new ?operator new works like malloc.What is difference between template and macro?There
15、 is no way for the compiler to verify that the macro parameters are of compatible types. The macro is expanded without any special type checking.If macro parameter has a postincremented variable ( like c+ ), the increment is performed two times.Because macros are expanded by the preprocessor, compil
16、er error messages will refer to the expanded macro, rather than the macro definition itself. Also, the macro will show up in expanded form during debugging.for example:Macro:#define min(i, j) (i j ? i : j)template:template T min (T i, T j) return i j ? i : j;What are C+ storage classes?autoregisters
17、taticexternauto: the default. Variables are automatically created and initialized when they are defined and are destroyed at the end of the block containing their definition. They are not visible outside that blockregister: a type of auto variable. a suggestion to the compiler to use a CPU register
18、for performancestatic: a variable that is known only in the function that contains its definition but is never destroyed and retains its value between calls to that function. It exists from the time the program begins executionextern: a static variable whose definition and placement is determined wh
19、en all object and library modules are combined (linked) to form the executable code file. It can be visible outside the file where it is defined.What are storage qualifiers in C+ ?They are.constvolatilemutableConstkeyword indicates that memory once initialized, should not be altered by a program.vol
20、atilekeyword indicates that the value in the memory location can be altered even though nothing in the programcode modifies the contents. for example if you have a pointer to hardware location that contains the time, where hardware changes the value of this pointer variable and not the program. The
21、intent of this keyword to improve the optimization ability of the compiler. mutable keyword indicates that particular member of a structure or class can be altered even if a particular structure variable, class, or class member function is constant.struct datachar name80;mutable double salary;const
22、data MyStruct = Satish Shetty, 1000 ; /initlized by complierstrcpy ( MyStruct.name, Shilpa Shetty); / compiler errorMyStruct.salaray = 2000 ; / complier is happy allowedWhat is reference ?reference is a name that acts as an alias, or alternative name, for a previously defined variable or an object.p
23、repending variable with & symbol makes it as reference.for example:int a;int &b = a; What is passing by reference?Method of passing arguments to a function which takes parameter of type reference.for example:void swap( int & x, int & y ) int temp = x; x = y; y = temp;int a=2, b=3;swap( a, b );Basica
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 常见 英文 面试 笔试 题目
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内