C++/ Java Interview Questions - CDAC

1. From below choose the correct option?
a) !(p||q) !p || !q
b) !!!p = !p
c) p && q || r p && ( q || r )
d) None

2. Find the output of the following program?

main()
{
static i = 3;
cout>>i--
return i >0 ? main():0;
}

a) 333 b) 321 c) 111 d) Error

3. Find the output of the following program?

main()
{
charp[] = "%d
";
p[1] = 'c'c;
cout<<65;
}

a) 0 b) a c) A d) Error

4. Out of the below given statements which will return an integer?

a) int*s ( )
b) ( int* ) s( )
c) int ( *s ) ( )
d) int (**s)( )

5. Find the output of the following program?

char*myfunc(char*ptr)
{
ptr +=3;
return (ptr);
}
int main()
{
char*x,*y;
x="HELLO";
y=myfunc(x);
cout<< “y”<return 0;
}
a) HELLO b) LLO c) LO d) L

6. Find the output of the following program?

main()
{
int i = _1_abc(10);
cout<<--i;
}
{
int_1_abc(int i)
{
return(++i);
}

a) 10 b) 11 c) 9 d) Error

7. Out of the following operators which can’t be overloaded?

a) &; b) [ ] ; c) :: ; d) all the above;

8. If allocate is done like this, Choose the statement which will de-allocate it?

int *ptr = new int [ 25];

a) delete *pint; b) delete [ ] pint; c) delete pint [25]; d) all

9. How many times "hello world" will be printed?

void fun(int n)
{int i;
for (i = 0; i < = n; i ++)
{fun(n-i);
cout<}

a) infinite
b) zero
c) one
d) n times
Post your comment