剑知北美生活快报   版面列表   admin登录
JiansNet Logo


Sample C++ Computer Science Interview Questions

by JC, published: 2010-12-25 03:18 viewed: 673 times
想了解更多的美国生活窍门?请订阅: JC写的剑知北美生活快报。
What will be the results of “54 << 3"?
- None of these
- I don’t know
- 623
- 556
- 523
- 47
- 440
- 432
- 413

The fundamental storage unit in the C + + memory model is?
- int
- I don’t know
- double
- char
- byte
- bit

Which of the following is not a keyword?
- volatile
- union
- typeid
- try
- None
- mutable
- I don’t know
- dynamic_cast
- cast

What is this- “extern int a;” ?
- I don’t know
- Definition
- Declaration

What is this - “int f(int x) { return x+10; }” ?
- I don’t know
- Definition
- Declaration

What is this - “int f(int x);” ?
- I don’t know
- Definition
- Declaration

Can namespaces be nested?
- Yes
- No
- I don’t know
- Depends

May destructors have arguments?
- Yes
- No
- I don’t know

Where can you put a continue statement?
- Inside a function
- In or as a loop body
- In a nested loop
- I don’t know
- Everywhere in the program
- Elsewhere

Can a return statement be used into a void function?
- Yes, and nothing will happen
- Yes, and it will exit the function
- Yes, and it will be ignored
- No
- I don’t know
- Depends

Can a static member function be virtual?
- Yes
- No
- I don’t know
- Depends

Can unions have constructors and destructors?
- Yes
- No
- I don’t know

Can unions have virtual functions?
- Yes
- No
- I don’t know

Can the anonymous unions have private and protected members?
- Yes
- No
- I don’t know

Can the anonymous unions have function members?
- Yes
- No
- I don’t know

Can a bit-field be a static member?
- Yes
- No
- I don’t know

Can a friend template be defined within a class?
- Yes
- No
- I don’t know

What a function cannot return?
- Reference
- Pointer
- None of them
- I don’t know
- Array
- All of them

Is it possible to get the address of a constructor?
- Yes
- No
- I don’t know
- Depends

If we have class A with variable Name in it and write: “A *obj”, how do you invoke the Name variable?
- obj.Name
- obj->Name
- None of these will work
- I don’t know
- c and d will work
- All of these will work
- A.Name
- A->Name
- a and b will work

Can you overload the constructor?
- Yes
- No
- I don’t know

Where can you overload the “=” operator?
- It can’t be overloaded
- In an operator-member function
- In a friend function
- I don’t know
- Both b and c are true

What type is the [] operator, when talking about overloading it?
- Unary
- Not-defined
- I don’t know
- Binary

Which of these has the lowest precedence priority?
- ||
- |
- ^
- I don’t know
- ?:
- >>
- <<
- &&
- &

What will this do: for(;;)?
- Loop forever
- Illegal
- Ignored by the compiler
- I don’t know
- Crash the OS

Which of the following is evaluated first?
- ||
- I don’t know
- &&
- !

If you have “int main(int argc, char* argv[])” and invoke your program this way: prog.exe a.out -i 2 -g -x 3 4 What will be the value of argc?
- Other
- I don’t know
- a.out
- 7
- 3
- 2
- 0

If n=3, what will be the result of:
switch(n)
{
case '3':
cout << "wow n";
break;
case 3:
cout << "bab n";
break;
default:
cout << "heh n";
break;
}
- wow
- Undefined behaviour
- I don’t know
- heh
- Compiler error
- bab

What will be the result of:
int f(int a) { return ++a; }
int f(unsigned int a) { return --a; }
cout << f(5);
- Undefined behaviour
- I don’t know
- Compiler error
- 6
- 5
- 4

What will !((1 || 0) && 0) evaluate to?
- Wrong code
- Undefined behaviour
- I don’t know
- 1
- 0

If i = 5, what will be the result of:
do
{
cout << (--i)-- << " ";
} while(i>=2 && i < 5);
- It won’t enter the loop
- It will loop forever
- I don’t know
- Compiler error
- 4 3 2 1
- 4 3 2
- 4 2 1
- 4 2

What will be the result after running this code:
for(int i=0;i<3;i++)
{
cout << i << " ";
continue;
cout << 7 << " ";
break;
for(int j=0;j<1;j++)
cout << 5 << " ";
}
- None of these
- I don’t know
- 0 7 5 1 7 5 2 7 5
- 0 7 1 7 2 7
- 0 1 2

What will be printed on the screen after running:
int x=65, *p = &x;
cout << p << "__" << *p ;
- Program will crash
- Other
- MemoryAddress_65
- I don’t know
- Compiler error
- 65_MemoryAddress

In which header file is the function isalpha()?
- string.h
- Other
- ifstream.h
- I don’t know
- ctype.h
- conio.h

Which one is correct?
- int a; a = new sizeof(int*20);
- int a; a = new int[20];
- int a; a = new int(20);
- int *a; a = new sizeof(int*20);
- int *a; a = new int[20];
- int *a; a = new 20;
- I don’t know

How do you access the last cell of “int arr[123];”?
- Other
- I don’t know
- arr[124]…
- arr[123]…
- arr[122]…

May the main() function be overloaded?
- Yes
- No
- I don’t know

If we have:
int f(int x)
{
if(x>2)
return x + f(--x);
else
return 0;
}
What will be the resulf of: cout << f(5);
- Program will freeze
- Other
- I don’t know
- 6
- 12
- 10
- 0

If Foo is a member function of a class, which of the following uses of const is legal?
- void Foo(Squid& a) const;
- void Foo(const Squid& a);
- void Foo(const Squid& a) const;
- None of the above
- const void Foo(const Squid& a) const;
- All of the above
- I don’t know

If Foo is a static function in a class, which of the following uses of const is legal?
- void Foo(Squid& const a);
- void Foo(const Squid& a);
- void const Foo(Squid& a);
- void (Squid& a) const;
- I don’t know

Is it possible that a class does not have a name?
- Yes, but you can’t have objects from it
- Yes, and you can have objects from it
- No
- I don’t know

If we have this code:
char arr[8];
cin >> arr;
And this text is entered: “Hello World”, what there will be in “arr”?
- Other
- I don’t know
- Hello World
- Hello Wo
- Hello W
- Hello

If we have this code:
class A
{
public:
A() { cout << 1; }
~A() { cout << 2; }
};
class B : public A
{
public:
B() { cout << 3; }
~B() { cout << 4; }
};
And we create an object from class B, what will be the result?
- Other
- I don’t know
- 3412
- 3142
- 3124
- 1342
- 1324
- 1234

What will be the result of: cout << (5 << 3); ?
- I don’t know
- Compiler error
- 53
- 40
- 35

What will be the result of: cout << 22/5*3; ?
- Other
- I don’t know
- 13.2
- 12
- 1.47
- 1

Which keyword specifies that an integer variable can not take negative values?
- unsigned
- There is not such a keyword
- positive
- Other
- long
- I don’t know

If we have: char a; , which one is incorrect?
- I don’t know
- All are correct
- a = 3;
- a = ‘3′;
- a = “3″;

What will happen if we have this code:
char a[3] = {’d',’w',’?′};
char b[3];
b = a;
- Other
- I don’t know
- Compiler error
- “b” will be unchanged
- “b” will be the same as “a”
Is this code legal?
int a; int b[a];
- Yes
- No
- I don’t know

If we have:
int a=9; //in the global space...
void f() { int a; a = 4; }
And if we type: cout << a; in the main() function, what will be the result?
- Other
- I don’t know
- 9
- 4
- 0

If we have this code:
class A { public: int a; };
A *obj;
How do we access the “a” variable?
- obj::a
- obj.a
- obj-a
- obj->a
- I don’t know

Which of these has the highest precedence?
- I don’t know
- /
- ++
- +
- *
- ()
Comments (4)
1. visitor 2009-04-08 17:36
whether None of these is the answer to the first problems? Since we do not know the type of 54.
please give some comments, THX
2. JC 2009-04-08 17:39
hmm, good thinking. I am not sure either. Need to do some research and post back...
3. JC 2009-04-08 21:38
I used java to run it: System.out.println(54 << 3);
got the answer: 432.

I don't think it relates to the type. Just simple math as follows:
54 in binary is 110110. So, 110110 << 3 => 110110000, which is:
2^8 + 2^7 + 2^5 + 2^4 = 432
4. visitor 2010-12-25 03:18
Can a static member function be virtual?
本文版权属于美国剑知信息网。如需转载,请先同我们联系。
订阅JC写的剑知北美生活快报,您会了解到更多的美国生活窍门。
Related Articles:
• Worldquant Interview Questions
• Common Computer Science Interview Questions
• Computer Science Interview Question - Two Eggs And 100 Story Building
美国职业发展 | 返回顶部 | 返回首页
About Us | Advertise with Us | Privacy Policy
Copyright © 2007-2016, All Rights Reserved.