Tuesday, September 6, 2011

Test your skills on C

1. Which one is correct, according to the ANSI specifications?a) int main()
b) void main()
c) void main(void)
d) I don't know


2. What will be the results of "54 << 3"?
a) 432
b) 440
c) 413
d) 47
e) 523
f) 556
g) 623
h) None of these
i) I don't know


3. The fundamental storage unit in the C + + memory model is?a) bit
b) byte
c) int
d) char
e) double
f) I don't know
4. Which of the following is not a keyword?a) try
b) union
c) typeid
d) cast
e) mutable
f) dynamic_cast
g) volatile
h) None
i) I don't know


5. What is this- "extern int a;" ?a) Declaration
b) Definition
c) I don't know


6. What is this- "int f(int x) { return x+10; }" ?a) Declaration
b) Definition
c) I don't know 
. What is this- "int f(int x);" ?a) Declaration
b) Definition
c) I don't know


8. Can namespaces be nested?
a) Yes
b) No
c) Depends
d) I don't know


9. May destructors have arguments?a) Yes
b) No
c) I don't know
10. Where can you put a continue statement?a) Everywhere in the program
b) Inside a function
c) In or as a loop body
d) In a nested loop
e) Elsewhere
f) I don't know


11. Can a return statement be used into a void function?a) Yes, and it will exit the function
b) Yes, and it will exit the program
c) Yes, and nothing will happen
d) No
e) Depends
f) I don't know


12. Can a static member function be virtual?a) Yes
b) No
c) Depends
e) I don't know
13. Can unions have constructors and destructors?a) Yes
b) No
c) I don't know


14. Can unions have virtual functions?
a) Yes
b) No
c) I don't know


15. Can the anonymous unions have private and protected members?a) Yes
b) No
c) I don't know
16. Can the anonymous unions have function members?a) Yes
b) No
c) I don't know


17. Can a bit-field be a static member?a) Yes
b) No
c) I don't know


18. Can classes be nested?a) Yes
b) No
c) Depends
e) I don't know

19. Can a friend template be defined within a class?a) Yes
b) No
c) I don't know


20. What a function cannot return?
a) Reference
b) Array
c) Pointer
d) None of them
e) All of them
f) I don't know


21. Is it possible to get the address of a constructor?a) Yes
b) No
c) Depends
e) I don't know
22. If we have class A with variable Name in it and write: "A *obj", how do you invoke the Name variable?a) A.Name
b) A->Name
c) obj.Name
d) obj->Name
e) All of these will work
f) None of these will work
g) a and b will work
h) c and d will work
i) I don't know


23. Can you overload the constructor?a) Yes
b) No
c) I don't know


24. Where can you overload the "=" operator?a) It can't be overloaded
b) In a friend function
c) In an operator-member function
d) Both b and c are true
e) I don't know 
25. What type is the [] operator, when talking about overloading it?a) Unary
b) Binary
c) Not-defined
d) I don't know


26. Which of these has the lowest precedence priority?
a) &
b) ^
c) |
d) &&
e) ||
f) ?:
g) <<
h) >>
i) I don't know


27. What will be the result of 100/10*2?a) 5
b) 20
c) Other
d) I don't know
28. What will be the results of 1000/100%7*2?a) 6
b) 1000
c) 250
d) 10
e) Other
f) I don't know


29. What will this do: for(;;)?a) Loop forever
b) Crash the OS
c) Illegal
d) Ignored by the compiler
e) I don't know


30. Which of the following is evaluated first?a) &&
b) !
c) ||
d) I don't know 

No comments:

Post a Comment