网上收集的C++笔试题目(2)

原创 2010年06月10日 13:15:00

说明:下划线是我认为的答案,仅供参考。

【Q1】 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.

 

【Q2】 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.

 

【Q3】 Which of the following are not pre-processor directives in C++?

A.    #ifndef

B.    #ifdef

C.    #elif

D.    #define

E.    #extern

 

【Q4】 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)

 

【Q5】 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.

 

【Q6】 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&)

 

【Q7】 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

 

【Q8】 Which of the following template declarations provide the correct syntax to write a template class

template <class T> class Derived;

that has to inherit from another template class

template <class T> class Base;

 

A.    template <class T, class Q> class Derived<Q> : public Base<T>

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

B.    template <class T, class Q> class Derived : public Base

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

C.    template <class T, class Q> class Derived : public Base<T>

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

D.    template <class T, class Q> class Derived<Q> : public Base

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

E.    template <class Q> class Derived<Q> : public Base

 

【Q9】 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.

 

【Q10】 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 a try...catch block.

 

 

版权声明:本文为博主原创文章,未经博主允许不得转载。

笔试题目收集(2)

1.下列程序运行的结果:(面试宝典P108) #include #include using namespace std; class classType{ private: int x,y;...
  • u010064842
  • u010064842
  • 2013年06月09日 16:18
  • 2286

某公司初中级C++笔试题目

初试试题(复试从里边抽查现场做) 姓 名: 应聘职位: 学 ...
  • InvisibleMiner02
  • InvisibleMiner02
  • 2014年12月19日 16:57
  • 1734

100条经典C++语言笔试题目-前50题

链接至100条经典C++语言笔试题目-后50题
  • sinat_20265495
  • sinat_20265495
  • 2016年12月03日 10:04
  • 1131

阿里笔试部分题目分析(2015实习生 C/C++研发)

1、 找出海量数据(N)中的最大值K(
  • u012896140
  • u012896140
  • 2015年04月19日 20:54
  • 910

2016年阿里C/C++开发笔试程序题一

include “iostream”using namespace std; struct pair_t { int a,b; }; struct node_t { in...
  • mnmdsf
  • mnmdsf
  • 2015年08月23日 16:51
  • 1050

经典C++笔试题目--100(编程练习(比C要难)(91-100))

编程练习(比C要难)(91-100) 91、请编写一个 C 函数,该函数给出一个字节中被置 1 的位的个数。  【参考答案】 unsigned int TestAsOne0(char...
  • xiangjai
  • xiangjai
  • 2016年08月25日 16:09
  • 6825

网上收集的Android 题目一

1、Activity生命周期说下,出现异常主要在那个阶段处理? 2、数据存储有哪几种方式?说过你用过哪些,做了哪些相关的项目?Sqlite用过说下? 3、Adapter原理说下。适配器具体用来干什...
  • thinkinwm
  • thinkinwm
  • 2013年03月05日 21:35
  • 781

Morgan Stanley(摩根斯坦利)笔试加电面试题大全

1经历了两次网上测试和两次电面,发现网上测试和电面题目都是不变的,电面题目相当固定,具体试题如下: (当时精心准备了所有的电面试题,整理出了两个word文档,有很多图片辅助理解,现在将重要内容写到这里...
  • zhangzhuoyang
  • zhangzhuoyang
  • 2017年05月31日 19:40
  • 813

c++ 笔试面试题 难题精选 持续更新

//第一题 问下面的输出结果是 什么?#include #include using namespace std; class A { protected: int m_data; pub...
  • hnust_xiehonghao
  • hnust_xiehonghao
  • 2014年04月06日 19:42
  • 1875

收集的腾讯笔试题目

腾讯是国内数一数二的IT企业了。那么每年想要进入腾讯公司的应聘者也是络绎不绝。那么一个好的笔试答卷绝对是脱颖而出的亮点。现在就来看看腾讯笔试题都有哪些内容吧。 腾讯笔试题:const的含义及实现...
  • chenmizhiren
  • chenmizhiren
  • 2015年04月13日 17:26
  • 292
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:网上收集的C++笔试题目(2)
举报原因:
原因补充:

(最多只允许输入30个字)