C++/Java Interview Questions - McAfee

1. Out of the following which represents a correct declaration of NULL?

a) typedef((void*)0) NULL;
b) #define NULL ((void *)0)
c) typedef NULL(char *)0;
d) #define NULL((char*)0)

2. Which function releases allocated memory?

a) calloc() b) dealloc() c) release() d) free()

3. What is the value of i in the following code?

i = 0;
j = 0;

a) 0 b) 1 c) 3 d) 9

4. What will happen out of the following if class inherits both virtual and non-virtual instance of a base class?
a) derived class has base objects only from the non virtual instance
b) base class has derived objects only from the non-virtual instance
c) derived class has base objects only from the virtual instance
d) derived class has a base object from the virtual instance and a base object from non-virtual instance.

5. What is the output of the following program?
class Word
Word(const char*,int = 0);};

a) 0 b) 4 c) Error d) None

6. How many different types of variable exists in C++?
7. How to use extern in a function declaration?
8. What is namespace?
9. Write syntax for copy constructor?
10. Write an example to show the use of pure virtual function?
11. If the static modifier is removed from the signature of the main method, what output it will produce?

a) Runtime error
b) Will compile normally
c) Compiler error
d) None

12. finalize() is used for
a) initialization
b) definition
c) garbage collection
d) none

13. java API is
a) large collection of ready made software components
b) static variables
c) dynamic variables
d) none

Post your comment