admin 管理员组

文章数量: 887021


2023年12月22日发(作者:公司网站营销)

IKM C++ Test

测试规则

经过了2个多小时的鏖战,总算是完成了传说中的IKM C++ Programming test,

中介的信上说要在 3rd Oct 3:00AM 前完成它,于是我花了两天半时间把所有可以看得,能够成为知识点的都看了个遍(后来发现我真是很傻很天真,这份考卷的难度远远大于我的预计),好在中介信上有说明如果INTENET断线了该怎么处理,这个给我后面的投机取巧埋下了伏笔。不过这个已经是我这辈子做过的最难的C++ test 了,上个学期的C++ 课的卷子老师已经出的很难了,但是和这个相比,哎,差距太大了。完成考试后,成绩马上递到我邮箱,不是很理想啦,分数是还好,但是在所有参与者里面的排名是很低的。55555下面开始总结经验吧。

先说说看这个考试吧,要求很多,一个很不好应付的考试。

1,每一题有5个选项,但是最多只能选3个答案,多选哦

2,每一题最多只能选3个答案。(和第一条是一样的哦,翻译过来就是这样的啦.........)

3,如果某一题实在不会,建议跳过。(对于每一题里面的每一个选项,如果选择错误的选项,扣分,选择正确的选项,得分,对于每一题,回答的完全正确,得分,回答不完全正确,扣分,如果跳过题目,扣分。额,把答题者往死里整就是了........)

4,如果可以将正确答案的范围缩小到两个答案,并且你选择这两个是可以保证一个是正确的情况下,建议你选择这两个,因为这样可以拿分。

5,如果一题已经被答过了或者被跳过了,是不能回去重新答题的。

6,答题的准确性比答的快更重要。

7,对每一个问题,当问题全部显示在浏览器上时,才开始计算时间。

8,一旦测试开始,必须一直接续直到测试结束。(其实是可以断线的啦..............)

测试结果

最后成绩不好呢,归根结底还是自己的实力的问题,在很多题上时间花的太多了,时间花的很多也直接导致了我最后排名的不高。如果很精通程序很精通概念了,那么应该是

可以很快做完的。最最后上图吧:

测试经验

第一,开着google,开着金山词霸(虽然没有怎么用到),开着MSDN(有几次救险),开着截图工具的方法是对的,是有效可行的。

先说google和MSDN,因为IKM测试里面的问题有一些问的很巧妙,而且选项有多,特别是关于概念性的问题比较多,考的知识点很细很散,遇到很概念的问题(还不少),因为平时基本不会接触到,比如异常处理的时候,抛出什么句柄之类的,是否回收资源之类的,STL的container adapter之类的(这个就是当场查出来的,我根本不会),MSDN可以帮上很大的忙。但是如果遇到一些不是很概念的问题,比如,关于友元类和几个类继承关系在一起的时候,我当时就直接晕了, 就可以找google。

总结:纯概念性的问题,还是要看MSDN,因为MSDN 最全面,但是有的时候google可以搜到IBM的帮助文件,也很有帮助,其他概念性有模糊的地方,需要google.

第二, 金山词霸有一定的帮助,做题的时候遇上有一些词真的不知道什么意思,查!所以先把它开着。

第三, 截图工具,每一道题一出来,第一件事就是点快捷键截图,这里的题目每一题都不是那么简单,收集起来有时间慢慢想。

还有一个很大的教训,在IKM test 里面有为数众多的程序题(有差不多

40%--50%),一开始我一直以为这样一个经典的考试是有防拷贝机制的,我们的复制粘贴应该是无效的,前面n个题目我都是自己脑子想的,所以估计就死在这上面了,作了差不多20多题了以后,发现越来越多的程序题,而且居然还可以复制.......然后就开始后悔,感叹,叹生不逢时,上次我明明看到哪个阿渣说试题是不可以复制的,昨天我就在犹豫要不要安装编译器,如果我昨天装了多好了,我可以直接复制,运行,看答案了.......痛定思痛,干脆一不做二不休,月黑风高杀人夜,日照香炉生紫烟,直接禁止无线网络连接,先断网,然后开始安装,中间的半个小时真的很漫长,新浪开了又关关了又开,什么玻利维亚国脚集体退出国家队,TM他们怎么还不去死。安装完毕,测试确实可以运行了以后,打开网页,重新登入,接着上次的题目继续做,这下就好多了,期间有差不多5题是程序题,每题的答题时间不到30秒。但是前面答过的题估计就没戏了。

网申结束后2天收到邮件,通知进行IKM online

test,有C++, C#, Java可供选择,选择其一即可。收到邮件后,开始在网上收IKM的相关资料,但很遗憾,没有找到原题。从查到的信息来看,大概是说这个测试很难,题目是adaptive的。另外可以找到考试的说明,大概来说,题目都是选择题,答题的正确率比速度更重要等等。

也不知道怎么准备。。于是开着google,旁边放本C++

premier就开始做题。选的是C#的题目,一共35分钟。题目范围很广,涉及到多线程(lock等知识点)、内存管理、调试、界面类(与C#对应)、多态继承以及一些设计模式的问题。另外,还有给个程序,让你指出哪里有错误的题目。题目确实很难,而且大部分题一时半会是查不到。我做题速度很慢,一共只做了20多道题,估计要挂。

另外,之前在网上查到一篇博客说,考试的时候可以复制题目,我试着复制了一下,立刻弹出一个警告,说考试题目不允许复制,要是再复制的话,考试将自动终止。所以,题目是不能直接复制的。

题目太难,好多都是我不熟悉的,所以也没记住太多信息。Anyway,希望对大家有帮助!

发表于 2012-3-21 16:26:12

“楼上很厉害啊,我考的JAVA,做了大概20道的样子,坑爹的5选项不定选择,全是考什么异常静态类之类的东西,还有大量的uml题,能把英文看懂就不错了,算了反正没啥希望了,还是等好好复习下再继续参加其他的笔试

发表于

2012-3-22 17:44:06

刚做完了,只做了17道。貌似题目都是看上去不难(我的意思是以概念题为主,看来我悲剧了,做的太差,系统默认给我越来越简单了),当然我还是不会做就是了。悲剧啊。。

选的C++,貌似主要考C++、面向对象和unix线程的一些概念。

发表于

2012-3-23 10:10:41

我做了java的,做了感觉答的很不好,后来闲着没事又把C++的做了,题目很多都一样啊。不知道什么情况。2周了快,没消息。估计挂了。期待楼主的好消息。

发表于

2012-3-30 09:55:46

没有,全是选择题。主要考 C,面向对象和unix操作系统一些东西。

发表于 2011-11-5 14:18:31

我做的Java,知识覆盖挺广的,数据库(Sybase)、OS、UML,被活虐了,做完好久了,一直没有信儿,估计挂掉了

__________________________________________________________

大摩IT笔试 (2012-03-29 16:48:57)

昨晚进行的大摩IT的笔试,在此略微描述mark下。

一共三种语言,C++,C#和JAVA,选择我的老本行,JAVA。时间35分钟,全英文,全选择,多选题,每题5个选项,至多3个正确答案。算分规则是:正确答案选中的加一分,不该选的选了减一分,改选的没选减一分。难度根据你前面的答案正确率和做题的速度会改变,做得越好往后越难,反之。

我一共做了30题,感觉难度也没怎么增加,也没怎么减少,一开始做得很慢,总想选的很对,很全,后来觉得实在太慢了,遂加速,答案跟着感觉来。。。估计后面正确率直线下降了。

考了很多方面,OO,JAVA语言,网络,Unix,数据结构,设计模式,最诡异的数据库居然考的Sybase,还考了两题,完全不懂,sigh。。

OO主要考一些概念,比如动态绑定静态绑定,类的aggregation,association等关系。

JAVA语言有考到好几个编程题,主要形式是给代码,让你写答案。

网络,考到了TCP/IP协议,OSI七层中的传输层和物理层。

Unix,一些基本命令,貌似有个关于JVM的题目分类在这里,选择命令的,具体题目……忘了。。

数据结构,记得的不太多了,这悲催的记忆,刚刚一个面试就给忘了,唉。。

设计模式,好像有strategy和bridge什么的比较,具体用来解决哪种问题。还有一题关于facade,大概形式就是给个图,问你哪个模式最适合。

Sybase就不说了,一题直接忽略(还是要扣分的,因为该选的没选啊。。。),还有一题跟着感觉就给选了。。

其他的,记得不太多了。

大体总结下,基础知识还是很重要的,基本都是考的基础,细节啊,基本概念啊。然后就是覆盖面,还是挺广的,别看是JAVA相关,基本覆盖了所有的知识。

最后,说下那个系统。我只是忘了把翻译词典的划词功能关掉,直接给我判定为作弊了,呜呜,还好有两次机会。。

不知道有没有机会电面,感觉挺玄的样子。

END

测试例题(71道)

Assessment C++ PROGRAMMING

If you lose your internet connection, you will be able to resume the test at the

point at which it was interrupted. Simply close your browser window(s) using the "Alt"

and "F4" keys, reconnect your internet connection and log back on using the above URL

and password (prior to the test expiration date and time). For other helpful hints, see

our Technical Support Tips (which we encourage you to print out before you begin the

test). You must complete these assessments by 2009/01/27 21:16 EST. After this time,

the passwords will no longer work, and you will need to contact your test administrator

to get new working passwords. Good luck!

IKM Assessment Administration

Ref: /doc/

 Question 4: Which of the following statements correctly describe the code below in

C++?

#define language 437 //Line 1

#if language < 400

#undef language //Line 2

#else //Line 3

#define language 850 //Line 4

#ifdef language //Line 5

printf("%d", language); //Line 6

#endif

#endif

A. An error or warning will occur on Line 6 because a macro cannot be used as

part of a preprocessor directive.

B. An error or warning will occur on Line 2 because #undef is not a valid preprocessor

directive.

C. An error or warning will occur on Line 4 because language has already been defined.

D. If Line 1 is changed to #define language 300, Line 6 will print "850".

E. An error or warning will occur on Line 3 because #else can only be used as the last

conditional in the chain.

Answer: D

 Question 5: Which of the following statements regarding the benefits of using template

functions over preprocessor #define macros are correct?

A. A preprocessor macro expansion cannot work when user-defined types are passed to

it as arguments.

B. Since the preprocessor does the macro expansion and not the compiler, the build process

takes a longer period of time.

C. While expanding #define macros, the preprocessor does no type checking on the

arguments to the macro.

D. A preprocessor macro expansion incurs a performance overhead at runtime.

E. It is simple to step into a template function code during the debugging process.

Answer: E

 Question 6: Which of the following are container adapters in the STL (Standard Template

Library) in C++?

A. list

B. map

C. stack

D. queue

E. deque

Answer: C D

Question 7: Which of the following correctly identify benefits of the getline() member

function for cin over the extraction operator in C++?

A. The getline() function by default, accepts whitespace, and returns on seeing the

n character, whereas the extraction operator returns when it encounters any whitespace

character.

B. Delimiters indicating end of input can be specified to the getline() function,

whereas the extraction operator has no such facility.

C. The getline() function can be overloaded to accept different argument types,

whereas the extraction operator cannot be overloaded.

D. The number of bytes to read can be specified to the getline() function, whereas

it cannot be done with the extraction operator.

E. The getline() function can be used like a manipulator with cin, whereas the

extraction operator cannot be used as a manipulator.

Question 8: In which of the following scenarios is a Copy Constructor called or

invoked?

A. When no conversion function exists for converting the class object to another

class object

B. When an existing object is assigned an object of its own class

C. When a function receives as an argument, an object of the class, by value

D. When a function returns an object of the class by value

E. When creating an object and initializing it with an object of its own class

Answer: B C D E

Question 9: Which of the following statements correctly describe the results of

executing the code below in C++?

#include

using namespace std;

class ExBase

{

private:

static int stat;

public:

static int GetStat(){ return stat; }

};

int ExBase::stat = 25;

class ExDer1 : public ExBase

{

public:

friend int Der1Fn(){ return ExBase::stat; }

};

class ExDer2 : public ExBase{};

class ExDer : public ExDer1, public ExDer2{};

A. int main()

{

ExDer d;

cout << 1Fn() << endl;

}

will result in an ambiguity error from the compiler.

B. int main()

{

ExDer d;

cout << t() << endl;

}

will display an output as

"25".

C. int main()

{

cout << ExDer1::GetStat() << endl;

}

will result in an ambiguity error from the compiler.

D. class ExDer1 : public ExBase

{

public:

friend int Der1Fn(){ return ExBase::stat; }

};

will result in an access error from the compiler.

E. int main()

{

cout << ExDer1::ExBase::GetStat() << endl;

}

will display an output as

"25".

Answer:

Question 10: Given the following program snippet, what can we conclude about the

use of dynamic_cast in C++?

#include

#include

//Someone else's code, e.g. library

class IGlyph

{

public:

virtual ~IGlyph(){}

virtual std::string Text()=0;

virtual IIcon* Icon()=0;

//...

};

class IWidgetSelector

{

public:

virtual ~IWidgetSelector(){}

virtual void AddItem(IGlyph*)=0;

virtual IGlyph* Selection()=0;

};

//Your code

class MyItem : public IGlyph

{

public:

virtual std::string Text()

{

return this->text;

}

virtual IIcon* Icon()

{

return this->();

}

void Activate()

{

std::cout << "My Item Activated" << std::endl;

}

std::string text;

std::auto_ptr icon;

};

void SpiffyForm::OnDoubleClick(IWidgetSelector* ws)

{

IGlyph* gylph = ws->Selection();

MyItem* item = dynamic_cast(gylph);

if(item)

item->Activate();

}

A. The dynamic_cast ought to be a reinterpret_cast since the concrete type is

unknown.

B. The dynamic_cast is unnecessary since we know that the concrete type returned

by IWidgetSelector::Selection() must be a MyItem object.

C. The dynamic_cast is redundant, the programmer can invoke Activate directly,

e.g. ws->Selection()->Activate();

D. The dynamic_cast is necessary since we cannot know for certain what concrete

type is returned by IWidgetSelector::Selection().

E. A polymorphic_cast should be used in place of the dynamic_cast.

Answer:

 Question 11: Which of the following statements describe the result when standard

new cannot allocate the requested storage in C++? (Note: older compilers may not

implement standard behavior).

A. It throws a bad_alloc exception.

B. It returns null.

C. It returns silently with no effect on the expression.

D. It throws an insufficient_memory exception.

E. It logs an error message to the mem_ file.

Answer:

Question 12: In C++, which of the following is the best declaration for an overloaded

operator[] to allow read-only access (and only read-only access) to the data?

template

class MyArray

{

//declaration goes here

};

A. T& operator[](size_t i);

B. const T& operator[](size_t i);

C. const T& operator[](size_t i) const;

D. T& operator[](size_t i)const;

E. T& operator[](const size_t i);

Answer: C

 Question 13: Which of the following declarations of function main are standard or

standard conforming extensions? (Please note that some compilers accept ill-formed

main declarations, these should be considered incorrect).

A. int main()

B. void main(char* argv[], int argc)

C. int main(int argc, char* argv[])

D. void main()

E. int main(int argc, char* argv[], char* arge[])

Answer: C

program below?

 Question 14: What is the correct declaration for a file stream insertion operator

for a class my_stuff::my_class as indicated in the C++ code snippet below?

#include

namespace my_stuff

{

class my_class

{

public:

int i;

};

//Declaration goes here

}//ns my_stuff

A. std::ofstream& operator<<(std::ofstream& ofs, const my_class&);

B. const my_class& operator<<(const my_class&)

C. std::fstream& operator<<(std::fstream& fs, const my_class&)

D. std::ifstream& operator<<(std::ifstream& ifs, const my_class&)

E. void operator<<(const my_class&)

Answer:

 Question 15: Which of the following statements describe the results of executing

the code snippet below in C++?

int var = 1;

void main()

{

int i = i;

}

A. The i within main will have an undefined value.

B. The compiler will allow this statement, but the linker will not be able to

resolve the declaration of i.

C. The i within main will have a value of 1.

D. The compiler will not allow this statement.

E. The result is compiler-dependent.

Answer:

 Question 16: Which of the following methods can a developer use to override the default

terminate() function in C++?

A. Write the terminate() function with two int arguments.

B. Write the terminate() function with a runtime_error argument.

C. Pass the address of the overriding function to the set_terminate() function.

D. Write the terminate() function with one int argument.

E. Write the terminate() function with a runtime_exception argument.

Answer:

program below?

 Question 17: Which of the following identify const-correctness failures in the C++

template

class MyArray

{

public: MyArray();

MyArray(MyArray& copy);

MyArray& operator=(MyArray& copy);

//...

};

class MyData

{

public:

MyData(MyArray& x, MyArray& y);

//...

const MyArray& x();

const MyArray& y();

};

MyArray read_data(int*, char**);

void make_changes(MyData* edit);

int main(int argc, char* argv[])

{

const MyArray read_x = read_data(&argc, argv);

const MyArray read_y = read_data(&argc, argv);

MyData user_data(read_x, read_y);

MyData edit_buffer(user_data);

make_changes(&edit_buffer);

}

A. MyData(MyArray& x, MyArray& y); should be

MyData(const MyArray& x, const MyArray& y);

B. MyArray& operator=(MyArray& copy); should be

const MyArray& operator=(const MyArray& copy);

C. void make_changes(MyData* edit); should be

void make_changes(const MyData* edit);

D. MyArray(MyArray& copy); should be

MyArray(const MyArray& copy);

E. const MyArray& operator=(const MyArray& copy); should be

const MyArray& operator=(const MyArray& copy) const;

Answer:

Question 18: In the given C++ code snippet, which of the following statements correctly

identify how Mon of enum DOW can be assigned to a variable named var?

void main()

{

const int Mon = 1, Tue = 2;

enum DOW{ Mon = 11, Tue = 12 };

...

A. The variable var will have to be of type enum DOW, and then defined as:

var = Mon;

B. Mon of enum DOW cannot be assigned because the compiler will give a redefinition

error.

C. Since enum DOW has been declared and defined later, it will be pushed onto

the stack later, but will be accessed first. Hence, the scope resolution operator is

not required and var will be assigned as:

var = Mon;

D. Since Mon is of type enum DOW, var will be assigned as:

var = DOW::Mon;

E. The variable var must be of type const int, and then it can be assigned as:

var = static_cast(Mon);

Question 19: Which of the following are not pre-processor directives in C++?

A. #ifndef

B. #ifdef

C. #elif

D. #define

E. #extern

Question 20: Which allocator member function do standard containers use to acquire

storage for their elements in C++?

A. std::allocator<>::allocate(size_t)

B. std::allocator<>::malloc(int)

C. std::allocator<>::make(size_t)

D. std::allocator<>::new(size_t)

E. std::allocator<>::acquire(size_t)

 Question 21: Which of the following statements provide a valid reason not to use

RTTI for distributed (i.e. networked between different platforms) applications in

C++?

A. RTTI does not have standardized run-time behavior.

B. RTTI uses too much memory.

C. RTTI is too slow.

D. RTTI's performance is unpredictable/non-deterministic.

E. RTTI frequently fails to function correctly at run-time.

Question 22: Which of the following functions of the ifstream class can be used

to determine the current position of the stream's get pointer in C++?

A. void tellg(pos_type&)

B. pos_type tellg()

C. pos_type tellp()

D. void tellp(pos_type&)

E. void seekg(pos_type&)

Question 23: Which of the following C++ keywords are designed to speed up execution

of a C++ function?

A. friend

B. static

C. extern

D. inline

E. member

Question 24: Which of the following template declarations provide the correct syntax

to write a template class

template class Derived;

that has to inherit from another template class

template class Base;?

A. template class Derived : public Base

where Q can be used as the templatized type for class Derived.

B. template class Derived : public Base

where Q can be used as the templatized type for class Derived.

C. template class Derived : public Base

where Q can be used as the templatized type for class Derived.

D. template class Derived : public Base

where Q can be used as the templatized type for class Derived.

E. template class Derived : public Base

Question 25: For the code snippet below, which of the following statements provide

the correct order of constructor calls when object obj is created in main()?

class Base

{

public:

Base(){cout << "In Base Ctorn";

}

class Nest

{

public:

Nest(){cout << "In Nest Ctorn"; }

};

};

class Derive : public Base

{

public:

Derive(){cout << "In Derive Ctorn"; }

};

void main()

{

Derive obj;

}

A. Base constructor

Derive constructor

B. Base constructor

Derive constructor

Nest constructor

C. Base constructor

Nest constructor

Derive constructor

D. Nest constructor

Base constructor

Derive constructor

E. Derive constructor

Base constructor

Nest constructor

Question 26: Which of the following options describe the expected overhead for a

class that has 5 virtual functions?

A. Every object of the class holds the address of a structure holding the addresses

of the 5 virtual functions.

B. Every object of the class holds the addresses of the 5 virtual functions.

C. Every object of the class holds the address of the first virtual function,

and each function in turn holds the address of the next virtual function.

D. Every object of the class holds the address of a link list object that holds

the addresses of the virtual functions.

E. Every object of the class holds the address of the class declaration in memory,

through which the virtual function calls are resolved.

Question 27: Which of the following reasons describe why a destructor cannot throw

an exception in C++?

A. It can invoke the terminate() handler.

B. Since the object is being destroyed, it is illogical to throw an exception

then.

C. The C++ language does not permit it; a throw statement in a destructor will

be caught as an error by the compiler.

D. A destructor may be invoked as a result of stack unwinding while an exception

is being handled.

E. A destructor in C++ cannot implement atch block.

Question 28: Which of the following statements accurately describe the new[] operator

in C++?

A. It calls the class default constructor for each element of the array.

B. It calls the class copy constructor for each element of the array.

C. It calls operator new[](size_t).

D. It calls operator new[](size_t, int).

E. It stores the number of objects allocated.

Question 29: The C++ code below generates a compiler error. Which of the following

solutions can be used to correctly access the member named nested?

class SomeClass

{

public:

int data;

protected:

class Nest

{

public:

int nested;

};

public:

static Nest* createNest(){return new Nest;}

};

void use_someclass()

{

SomeClass::Nest* nst = SomeClass::createNest();

nst->nested = 5;

}

A. Make function void use_someclass() a friend of class SomeClass.

B. Make the function createNest() a non-static function of SomeClass.

C. Declare the class Nest in public scope of class SomeClass.

D. Make the object nst a reference object, and make the function createNest()

return a Nest&.

E. Derive a class from SomeClass. Make the object nst a derived class pointer

so that it can access SomeClass's protected declarations.

 Question 30: What is the order of destructor calls for an object of class Y inherited

from class X that has an object of class A as data member of class Y in C++?

A. ~Y()

~X()

~A()

B. ~X()

~A()

~Y()

C. ~Y()

~A()

~X()

D. ~A()

~Y()

~X()

E. ~X()

~Y()

~A()

 Question 31: A C++ developer wants to handle a static_cast() operation for

the class String shown below. Which of the following options are valid declarations

that will accomplish this task?

class String {

public:

//...

//declaration goes here

};

A. char* operator();

B. char* operator char*();

C. String operator char*();

D. operator char*();

E. char* operator String();

 Question 32: In C++, there is a standard global object wcin of type wistream. What

is the template type of the wistream typedef?

A. std::basic_istream >

B. std::basic_istream >

C. std::istream >

D. std::istream >

E. std::wistream >

Question 33: How can a C++ developer use the placement new syntax to make new allocate

an object of class SomeClass at a particular memory address stored in a pointer type

variable named pmem?

A. new SomeClass(pmem);

B. new(pmem) SomeClass;

C. new pmem SomeClass;

D. new SomeClass pmem;

E. new (pmem, SomeClass);

Question 34: Under which of the following conditions will a C++ developer use

polymorphism?

A. When there is a looping construct that uses a continue more than once

B. When there is a need for the code written today to call code written tomorrow

C. When there is a need to check for the type of an object to determine which

function must be called

D. When there is a need to check the value of a variable to determine which of

two or more functions to call

E. When there is a need to modify the existing interface of a class

Question 35: Protected, or private, inheritance, as opposed to public inheritance,

models which type of relationship in C++?

A. Has-a

B. Is-implemented-in-terms-of

C. Was-a

D. Can-only-have-one-of

E. Shares-a-relationship-with

Question 36: Which of the following statements regarding functions' default arguments

in C++ are correct?

A. Default arguments cannot be of pointer type.

B. Default arguments cannot be of a user-defined type.

C. Default arguments can never precede non-default arguments.

D. Default arguments exist in the global heap and not on the function's stack.

E. Default arguments are not considered for generating the function's signature.

Question 37: In C++, which of the following statements regarding the code below are

valid?

#include

class Outer

{

int m_o;

public:

class Inner

{

int m_i;

public:

Inner(){}

Inner(Outer m_outer, int x)

{

m_outer.m_o = x;

}

};

Outer(int y)

{

m_inner.m_i = y;

}

void Display()

{

using namespace std;

cout << m_o << endl

<< m_inner.m_i << endl;

}

Inner m_inner;

};

void main()

{

Outer objOut(10);

Outer::Inner objIn(objOut, 5);

y();

}

A. The output will be:

5

10

B. Outer class cannot access its nested class's private members.

C. The relationship between class Inner and class Outer is not valid C++ syntax.

D. Inner class cannot access its containing class's private members.

E. The output will be:

10

5

Question 38: What is the output of the program below in C++?

#include

using namespace std;

class Object

{

public:

Object() {}

void Print() const

{

cout << "const" << endl;

}

void Print()

{

cout << "mutable" << endl;

}

};

void print_obj(const Object& obj)

{

();

}

int main()

{

Object obj1; const

Object obj2; Object*const

pobj1 = &obj1;

print_obj(obj1);

print_obj(obj2);

();

();

pobj1->Print();

return 0;

}

A. const

const

mutable

const

const

B. const

const

mutable

const

mutable

C. mutable

const

mutable

const

mutable

D. Undefined behavior

E. Fails to compile

Question 39: Which of the following are possible outputs of the C++ code below?

#include

class TestPrint

{

public:

void Print()

{

std::cout << "TestPrint" << std::endl;

}

void Print() const

{

std::cout << "const TestPrint" << std::endl;

}

void Print() volatile

{

std::cout << "volatile TestPrint" << std::endl;

}

void Print() const volatile

{

std::cout << "const volatile TestPrint" << std::endl;

}

};

int main(int argc, char* argv[])

{

TestPrint normal_test;

normal_();

const TestPrint const_test;

const_();

volatile TestPrint volatile_test;

volatile_();

const volatile TestPrint const_volatile_test;

const_volatile_();

}

A. TestPrint

const TestPrint

const volatile TestPrint

const volatile TestPrint

B. TestPrint

const volatile TestPrint

const volatile TestPrint

const volatile TestPrint

C. TestPrint

const TestPrint

volatile TestPrint

const volatile TestPrint

D. TestPrint

TestPrint

TestPrint

TestPrint

E. TestPrint

const volatile TestPrint

volatile TestPrint

const volatile TestPrint

Question 40: In the declaration below, p is a pointer to an array of 5 int pointers:

int *(*p)[5];

Which of the following statements can be used to allocate memory for the first

dimension in order to make p an array of 3 arrays of 5 pointers to type int?

A. p = new int [3][5]*;

B. p = new int (*)[3][5];

C. p = new int [3]*[5];

D. p = new int *[3][5];

E. p = new int (*[3])[5];

Question 41: Which of the following operators must be overloaded by function objects

in the Standard Template Library?

A. operator +()

B. operator ++()

C. operator ==()

D. operator ()()

E. operator []()

Question 42: A C++ developer wants to explicitly specialize the template function

below for the char * type:

template void fn(T a){...}

Which of the following methods can the developer use to carry out this specialization?

A. void fn(char* a){...}

B. template <> void fn(char* a){...}

C. void fn(T a){...}

D. template void fn(char* a){...}

E. template void fn(T a){...}

Question 43: Which of the following define valid string constants in C++?

A. #define MESSAGE "Whoever said that you could run this program" &

"must not have known what you'd do."

B. #define GREETING = "Hello!"

C. #define MESSAGE = "This is a long message, but I know you have"

#define MESSAGE = MESSAGE + " plenty of time to read it."

D. #define ERROR_MSG "You did something very very wrong and now the

program will terminate."

E. #define MESSAGE "Hello "

#concat MESSAGE & #UserName

Question 44: What member function of std::fstream could a C++ developer invoke in

order to change the target output filebuf of the fstream?

A. setbuffer

B. setfilebuf

C. rdbuf

D. filebuf

E. streambuf

 Question 45: Which of the following options are returned by the typeid operator in

C++?

A. A reference to a const std::type_info object

B. A const std::type_info object

C. A const reference to a const std::type_info object

D. A reference to a std::type_info object

E. A const reference to a std::type_info object

 Question 46: Which of the following statements describe correct methods of handling

C++ exceptions?

A. Once an exception is thrown, the compiler unwinds the heap, freeing any memory

dynamically allocated within the block from which the exception was thrown.

B. In a hierarchy of exception classes, the order of handling exceptions can be

from the most specific class to the most general class.

C. If an exception is caught by its address or pointer, it is the responsibility

of the thrower to release the memory occupied by the exception.

D. Catching an exception by reference is preferable to catching it by value.

E. To write an exception handler, it is essential to know the concrete class of

exception to catch.

Question 47: Which of the following statements correctly describe functions of the

endl manipulator for the ostream object cout in C++?

A. It only flushes the standard output stream.

B. It puts a newline character into the standard output stream and flushes the

standard output stream.

C. It puts an end-of-output character into the standard output stream.

D. It only puts a newline character into the standard output stream.

E. It indicates end-of-output and closes the standard output stream.

Question 48: In C++, which of the following statements accurately describe a base

class destructor calling a virtual function override of a derived class?

A. The base class destructor calls the virtual function override of the derived

class through the vtable.

B. The base class destructor cannot call the virtual function override of the

derived class because the derived class portion of the data may be in an undefined state.

C. The base class destructor calls the virtual function of the base class and

not of the derived class.

D. The C++ compiler maintains the overridden virtual function pointers in a

separate structure when it sees the call in a destructor. The call is then resolved through

this structure.

E. The language does not permit calling a virtual function override in either

a constructor or the destructor of the base class.

Question 1: Which of the following expression(s) will not cause an error when used

to replace the ***** in the C++ code excerpt below?

#include

class Outer

{

public:

static int m_Out;

class Inner

{

public:

static int m_In;

void Display();

};

};

int Outer::m_Out = 10;

int Outer::Inner::m_In = 25;

void Outer::Inner::Display() { std::cout << m_Out << std::endl; }

void main()

{

Outer objOut;

Outer::Inner objIn;

*****

}

A. objOut.m_In;

B. objIn.m_Out

C. y();

D. ::m_Out

E. ::m_In;

Answer: C

 Question 2: Which of the following statements accurately describe unary operator

overloading in C++?

A. A unary operator can be overloaded with one parameter when the operator function

is a class member.

B. A unary operator can be overloaded with one parameter when the operator function

is free standing function (not a class member).

C. A unary operator can only be overloaded if the operator function is a class member.

D. A unary operator can be overloaded with no parameters when the operator function

is a class member.

E. A unary operator can be overloaded with no parameters when the operator function

is a free standing function (not a class member).

Answer: B D

 Question 3: Which of the following statements describe the result when standard new

cannot allocate the requested storage in C++? (Note: older compilers may not

implement standard behavior).

A. It throws an insufficient_memory exception.

B. It returns null.

C. It throws a bad_alloc exception.

D. It returns silently with no effect on the expression.

E. It logs an error message to the mem_ file.

Answer: A B

 Question 4: Which of the following correctly identify benefits of the getline() member

function for cin over the extraction operator in C++?

A. The number of bytes to read can be specified to the getline() function, whereas

it cannot be done with the extraction operator.

B. Delimiters indicating end of input can be specified to the getline() function,

whereas the extraction operator has no such facility.

C. The getline() function by default, accepts whitespace, and returns on seeing

the n character, whereas the extraction operator returns when it encounters any

whitespace character.

D. The getline() function can be overloaded to accept different argument types,

whereas the extraction operator cannot be overloaded.

E. The getline() function can be used like a manipulator with cin, whereas the

extraction operator cannot be used as a manipulator.

Answer: B C

 Question 7: Which of the following functions of the ifstream class can be used to

determine the current position of the stream's get pointer in C++?

A. pos_type tellg()

B. void tellp(pos_type&)

C. void tellg(pos_type&)

D. pos_type tellp()

E. void seekg(pos_type&)

Answer:

 Question 8: In which of the following situations is the unexpected() handler called

in C++?

A. When a function throws an exception of an undefined type

B. When an appropriate catch block is not present in the calling function to catch

an exception thrown by the called function

C. When the stack gets corrupted during unwinding as a result of a thrown exception

D. When a function that has an "exception specification" throws an exception not

listed in that specification.

E. When a constructor throws an exception

Answer:

Question 11: Which of the following statements correctly describe the results of

executing the code below in C++?

#include

using namespace std;

class ExBase

{

private:

static int stat;

public:

static int GetStat(){ return stat; }

};

int ExBase::stat = 25;

class ExDer1 : public ExBase

{

public:

friend int Der1Fn(){ return ExBase::stat; }

};

class ExDer2 : public ExBase{};

class ExDer : public ExDer1, public ExDer2{};

A. int main()

{

cout << ExDer1::GetStat() << endl;

}

will result in an ambiguity error from the compiler.

B. class ExDer1 : public ExBase

{

public:

friend int Der1Fn(){ return ExBase::stat; }

};

will result in an access error from the compiler.

C. int main()

{

ExDer d;

cout << 1Fn() << endl;

}

will result in an ambiguity error from the compiler.

D. int main()

{

ExDer d;

cout << t() << endl;

}

will display an output as "25".

E. int main()

{

cout << ExDer1::ExBase::GetStat() << endl;

}

will display an output as "25".

Answer:

Question 22: In the given C++ code snippet, which of the following statements correctly

identify how Mon of enum DOW can be assigned to a variable named var?

void main()

{

const int Mon = 1, Tue = 2;

enum DOW{ Mon = 11, Tue = 12 };

...

A. Mon of enum DOW cannot be assigned because the compiler will give a redefinition

error.

B. The variable var will have to be of type enum DOW, and then defined as:

var = Mon;

C. Since Mon is of type enum DOW, var will be assigned as:

var = DOW::Mon;

D. Since enum DOW has been declared and defined later, it will be pushed onto the

stack later, but will be accessed first. Hence, the scope resolution operator is not

required and var will be assigned as:

var = Mon;

E. The variable var must be of type const int, and then it can be assigned as:

var = static_cast(Mon);

Answer:

 Question 23: Protected, or private, inheritance, as opposed to public inheritance,

models which type of relationship in C++?

A. Can-only-have-one-of

B. Has-a

C. Is-implemented-in-terms-of

D. Was-a

E. Shares-a-relationship-with

Answer:

 Question 29: Which of the following reasons describe why a destructor cannot throw

an exception in C++?

A. The C++ language does not permit it; a throw statement in a destructor will be

caught as an error by the compiler.

B. A destructor may be invoked as a result of stack unwinding while an exception

is being handled.

C. It can invoke the terminate() handler.

D. Since the object is being destroyed, it is illogical to throw an exception then.

E. A destructor in C++ cannot implement atch block.

Answer:

 Question 30: In C++, there is a standard global object wcin of type wistream. What

is the template type of the wistream typedef?

A. std::basic_istream >

B. std::istream >

C. std::basic_istream >

D. std::istream >

E. std::wistream >

Answer:

Question 32: The C++ code below generates a compiler error. Which of the following

solutions can be used to correctly access the member named nested?

class SomeClass

{

public:

int data;

protected:

class Nest

{

public:

int nested;

};

public:

static Nest* createNest(){return new Nest;}

};

void use_someclass()

{

SomeClass::Nest* nst = SomeClass::createNest();

nst->nested = 5;

}

A. Make function void use_someclass() a friend of class SomeClass.

B. Make the object nst a reference object, and make the function createNest() return

a Nest&.

C. Declare the class Nest in public scope of class SomeClass.

D. Make the function createNest() a non-static function of SomeClass.

E. Derive a class from SomeClass. Make the object nst a derived class pointer so

that it can access SomeClass's protected declarations.

Answer:

 Question 34: Which of the following define valid string constants in C++?

A. #define MESSAGE = "This is a long message, but I know you have"

#define MESSAGE = MESSAGE + " plenty of time to read it."

B. #define ERROR_MSG "You did something very very wrong and now the

program will terminate."

C. #define GREETING = "Hello!"

D. #define MESSAGE "Whoever said that you could run this program" &

"must not have known what you'd do."

E. #define MESSAGE "Hello "

#concat MESSAGE & #UserName

Answer:

 Question 35: Which allocator member function do standard containers use to acquire

storage for their elements in C++?

A. std::allocator<>::make(size_t)

B. std::allocator<>::new(size_t)

C. std::allocator<>::malloc(int)

D. std::allocator<>::allocate(size_t)

E. std::allocator<>::acquire(size_t)

Answer:

Question 36: A class der inherits from class base and the functions are defined in

the code below:

void SomeFunc(base& b){ ... }

void SomeFunc(base b){ ... }

void SomeFunc(der& b){ ... }

void SomeFunc(der b){ ... }

void main()

{

der d;

SomeFunc(d);

}

In the call to SomeFunc(d), which of the following overloads of the SomeFunc function

will be executed in C++?

A. void SomeFunc(base& b){ ... }

B. The compiler will generate an ambiguous call error.

C. void SomeFunc(der& b){ ... }

D. void SomeFunc(base b){ ... }

E. void SomeFunc(der b){ ... }

Answer:

Question 37: In the declaration below, p is a pointer to an array of 5 int pointers:

int *(*p)[5];

Which of the following statements can be used to allocate memory for the first

dimension in order to make p an array of 3 arrays of 5 pointers to type int?

A. p = new int (*)[3][5];

B. p = new int [3]*[5];

C. p = new int *[3][5];

D. p = new int [3][5]*;

E. p = new int (*[3])[5];

Answer:

 Question 39: Which of the following statements correctly describe functions of the

endl manipulator for the ostream object cout in C++?

A. It puts an end-of-output character into the standard output stream.

B. It only flushes the standard output stream.

C. It only puts a newline character into the standard output stream.

D. It puts a newline character into the standard output stream and flushes the standard

output stream.

E. It indicates end-of-output and closes the standard output stream.

Answer:

 Question 42: Under which of the following conditions will a C++ developer use

polymorphism?

A. When there is a need for the code written today to call code written tomorrow

B. When there is a looping construct that uses a continue more than once

C. When there is a need to check for the type of an object to determine which function

must be called

D. When there is a need to check the value of a variable to determine which of two

or more functions to call

E. When there is a need to modify the existing interface of a class

Answer:

Question 44: A C++ developer wants to explicitly specialize the template function

below for the char * type:

template void fn(T a){...}

Which of the following methods can the developer use to carry out this specialization?

A. template void fn(char* a){...}

B. template <> void fn(char* a){...}

C. void fn(T a){...}

D. void fn(char* a){...}

E. template void fn(T a){...}

Answer:

 Question 45: Which of the following classes must be instantiated so that the object

can be used both for reading and writing to the same file in C++?

A. stream

B. ofstream

C. fstream

D. ifstream

E. iostream

Answer:

 Question 46: The code below generates the compiler error "'Derived::data' is

ambiguous". In C++, which of the following steps can be taken to rectify it so that

obj has only one instance of data?

class Base

{

public:

int data;

};

class DerivedOne : public Base {};

class DerivedTwo : public Base {};

class Derived : public DerivedOne, public DerivedTwo {};

void main()

{

Derived obj;

= 5;

}

A. Inherit class Derived from DerivedOne and DerivedTwo as virtual public DerivedOne

and virtual public DerivedTwo.

B. Inherit classes DerivedOne and DerivedTwo from Base as virtual public Base.

C. Inherit classes DerivedOne and DerivedTwo from Base as public virtual Base.

D. Inherit class Derived from DerivedOne and DerivedTwo as public virtual DerivedOne

and public virtual DerivedTwo.

E. Inherit either class DerivedOne or class DerivedTwo from Base as virtual public

Base

Answer:

Question 48: Which of the following statements correctly describe the C++ language

and its libraries?

A. It is possible to declare a function pointer to the constructor of a C++ class.

B. Though one can override the << operator of the ostream class, it is not possible

to do so for the ofstream class because it does not use a buffered output stream.

C. The C++ language does not have built in features for persisting or serializing

objects to disk and back.

D. It is not possible to declare a pointer to a private data member of a C++ class.

E. If the << operator of the ostream class has been templatized, it cannot be

specialized.

Answer:

Question 3:In the C++ code segment below, which of the following lines of code

can be substituted for the ***** to display the contents of vector?

#include

#include

using namespace std;

void print(int i)

{

std::cout << i << std::endl;

}

int main()

{

vector iVec;

vector::iterator it;

for(int i=0; i<10; i++)

_back(i*5);

*****

return 0;

};

A. for_each((), (), print);

B. std::cout << *it << std::endl;

C. for_each((), (), print);

D. for(int i=0; i<10; i++)

(i);

E. std::cout << iVec[0-9] << std::endl;

Answer: C

 Question 11: Which of the following are C++ declare pointers that cannot be

changed? (As opposed to declaring a pointer to something that cannot be changed).

A. extern double* oddity;

B. extern float* const some_scalar;

C. extern const std::vector* global_vector;

D. extern const int* const reference_only;

E. extern const void* anything;

Answer: B D

 Question 18: Which of the following are true statements regarding the C++ code segment below?

map capitals;

map::iterator it;

string west = "California";

size_t numCiites, numStates;

(make_pair("NewYork", "Albany")); //missepelled

(make_pair("Texas", "Houston")); // wrong city

(make_pair("California","Sacramento"));

numCities = (west);

it = ("Houston"); // Alteration 1

it->second = "Austin"; // Alteration 1

it = ("NewYork"); // Alteration 2

it->first = "New York"; // Alteration 2

string ILap = capitals["Illinois"];

numStates = ();

A. The two lines indicated by the comment Alteration 2 are attempting to do

something that is not allowed in C++;

B. The two lines indicated by the comment Alteration 1 is a valid way to find

and alter this State/Capital-city pair;

C. The variable numCities accurately reflects the number of completes

State/Capital-city pairs;

D. The variable numStates accurately reflects the number of completes

State/Capital-city pairs;

E. After the initial 3 insertions, the map will be sorted such that the pair

containing Albany will be the first entry.

Answer: A B D

 Question 32: Which of the following are valid expressions using the new operator

in C++?

A. Doctor &dref = new Doctor;

B. Manager *mptr = new Manager;

C. Nurse nurses = new Nurse[5];

D. int *iptr = new int;

E. Employee *eptr = new Employee[10];

Answer: B D E


本文标签: 题目 考试 问题 答案 测试