Welcome Guest

Technical Questions for HSBC

Q. No. :1
Question :
main()
{
int i=2;
{
int i=4,j=5;
printf("%d%d",i,j);
}
printf("%d%d",i,j);
}
A :
will not compile successfully
B :
prints 4525
C :
prints 2525
D :
none of the above
Answer: A
Q. No. :2
Question :A pointer variable can not be
A :
passed to a function as arguement
B :
changed within a function
C :
returned by a function
D :
assigned an integer value
Answer: D
Q. No. :3
Question :The expression 4+6/3*2-2+7%3 evaluates to
A :
3
B :
4
C :
6
D :
7
Answer: D
Q. No. :4
Question :
main()
{
inc(); inc(); inc();
}
inc(){
static int x;
printf("%d",++x);
}
A :
prints 012
B :
prints 123
C :
prints 3 consecutive , but unpredictable number
D :
prints 111
Answer: B
Q. No. :5
Question :
Consider the following code fragment and select the correct option
 main()
{int x,c,a=10,b=20;
c=a * b ++;
x=a*b;
printf("%d%d%d",c,x,10<=11);
}
A :
200, 210, 1
B :
200, 200, 1
C :
210, 210, cannot be compare
D :
Error due to "10<=11"
Answer: A
Solution
Q. No. :6
Question :


main()
{
char str[7]="Strings";
printf("%s",str);
}
A :
Error
B :
Strings
C :
Cannot Predict
D :
None of the above
Answer: C
Q. No. :7
Question :
main()
{
int i=5;
i=(++i)/(i++);
printf("%d",i);
}
outputs
A :
2
B :
5
C :
1
D :
6
Answer: A
Solution
Q. No. :8
Question :Copy constructor is invoked when
A :
a function returns by value
B :
an argument is passed by value
C :
a function returns for reference
D :
an argument is passed by reference
Answer: A
Q. No. :9
Question :class dog:public x,public y is an example of
A :
multiple inheritance
B :
repeated inheritance
C :
linear inheritance
D :
none of the above
Answer: A
Q. No. :10
Question :Overloading is otherwise called as
A :
a virtual polymorphism
B :
transient polymorphism
C :
pseudo polymorphism
D :
ad-hoc polymorphism
Answer: D
Q. No. :11
Question :
Consider the following program segment
static char x[3]="1234";
cout << x;
A complete c++ program with these two statement
A :
prints 1234
B :
prints 123
C :
prints 1234 followed by some junk
D :
will give a compilation error
Answer: D
Solution
Q. No. :12
Question :
int i=10;
void main()
{
int i=20;
{
int i=30;
cout << i <<::i;
}
}
A :
prints 3010
B :
prints 3020
C :
will result in a run time error
D :
none of the above
Answer: A
Q. No. :13
Question :The member function can always access the data
A :
in the object of which is a member
B :
in the class of which it is member
C :
in any object of the class of which it is a member
D :
in the public part of its class
Answer: A
Q. No. :14
Question :The number of possible ordered trees with 3 nodes A,B,C is
A :
16
B :
12
C :
6
D :
10
Answer: B
Q. No. :15
Question :The depth of a complete binary tree with n nodes is
A :
log(n+1)-1
B :
log(n)
C :
log(n-1)+1
D :
log(n)+1
Answer: A
Q. No. :16
Question :The postfix equivalent of the prefix *+ab-cd is
A :
ab+cd-*
B :
abcd+-*
C :
ab+cd*-
D :
ab+-cd*
Answer: A
Q. No. :17
Question :A binary tree has n leaf nodes. The number of nodes of degree 2 in this tree is
A :
log2(n)
B :
n-1
C :
n
D :
2 raised to power n
Answer: B
Q. No. :18
Question :The maximum degree of any vertex in a simple graph with n vertices is
A :
n
B :
n-1
C :
n+1
D :
2n-1
Answer: B
Q. No. :19
Question :The number of edges in a regular graph of degree d and n vertices is
A :
maximum of n,d
B :
n+d
C :
nd
D :
nd/2
Answer: D
Q. No. :20
Question :Which of the following sorting algorithm has the worst time complexity of nlog(n)
A :
Heap Sort
B :
Quick Sort
C :
Insertion Sort
D :
Selection Sort
Answer: A
Q. No. :21
Question :The merging two sorted lists of size m and n into a sorted lists of size m+n , we require comparisions of
A :
O(m)
B :
O(n)
C :
O(m+n)
D :
O(log(m)+log(n))
Answer: C
Q. No. :22
Question : The worst case successful search time for sequential search on n items is
A :
n
B :
(n-1)/2
C :
(n+1)/2
D :
log(n)+1
Answer: A
Q. No. :23
Question :The recurrence relation T(1)=2
T(n)=3T(n/4)+n
has solution T(n) equal to
A :
O(n)
B :
O(logn)
C :
O(n raised to power 3/4)
D :
npne of the above
Answer: A