C++/ Java Interview Questions - SAP

1. What is the terminator that is used to terminate C++ code?
a) . (dot)
b) ; (semi-colon)
c) : (colon)
d) ' (single quote)

2. Out of the following which is a correct comment?
a) */ Comments */
b) ** Comment **
c) /* Comment */
d) { Comment }

3. Which type is not used in C++?
a) float
b) real
c) int
d) double

4. Which operator is used to compare two variables?
a) :=
b) =
c) equal
d) ==

5. Which is a boolean operator for logical-and?
a) &
b) &&
c) |
d) |&

6. Evaluate !(1 && !(0 || 1)).
a) True
b) False
c) Error
d) None of these

7. What is the output of the following program?
void main()
{
int a, *pa, &ra;
pa = &a;
ra = a;
cout «"a="«a «"*pa="«*pa «"ra"«ra ;
}
a) ra
b) ra ra ra
c) Compiler error
d) None of these

8. Write an algorithm that takes two strings as input, and returns the intersection of the two, with each letter represented at most once.

9. Write a program to find out the cycle in link list?

10. Write a program to automatically shuffle a deck of cards? [given that the cards are stored in an array of ints]
Post your comment