C++/ Java Interview Questions - MPhasis

1. What is the output of the following program?
int main()
{
static int h = 10;
cout< if(h)
main();
}

a) 10 9 8 7 6 5 4 3 2 1
b) 10
c) 9 8 7 6 5 4 3 2 1
d) None

2. What is the output of the following program?
int main()
{
int c[ ]={2.8,3.4,4,6.7,5};
int j,*p=c,*q=c;
for(j=0;j<5;j++) {
cout<<*c;
++q; }
for(j=0;j<5;j++){
cout<<*p;
++p; }
}

a) 2 2 2 2 2 2 3 4 6 5
b) 2 3 4 5 6 2 3 4 6 5
c) 2.8 3.4 4 6.7 5
d) None

3. What is the output of the following program?
int main()
{
int i=-1,j=-1,k=0,l=2,m;
m=i++&&j++&&k++||l++;
cout<}

a) 1 3 1 0 0
b) 0 0 1 3 1
c) Linking error
d) Compiler error

4. Write a program to get the size of the int using sizeof()?
5. What is the boundary problem in allocation of size of structures?
6. Write a program to reverse a doubly linked-list?
Post your comment

    Discussion

  • RE: C++/ Java Interview Questions - MPhasis -a.v.divya (12/25/14)
  • i need clear explanation with answers
  • RE: C++/ Java Interview Questions - MPhasis -sanjay kumar (11/09/14)
  • i want answers