C++/ Java Interview questions - CMC

1. Write the postfix and prefix form of the given expression below:
A+[[(B+C)+(D+E)*F]/G]
2. What is the function and use of the linker?
3. What will be output on execution of free(ptr)?
void f(int y){
struct s *ptr;
ptr = malloc (sizeof (struct)+99*sizeof(int));
}
struct s{
int i;
float p;};

4. How to concatenate two linked lists of order O(1)?
5. How many times i will be printed in the following program?

main()
{ int i=1;
fork();
fork();
fork();
cout< }

a) 8 b) 10 c) 11 d) None of this

6.What is the output of the following program?

int i=0xaa
char *p;
p=(char *)i;
p=p>>4;
cout<
a) 0x000000a; b) 0x000000b; c) 0x00000a; d) None

7. What is the size of the union in the following program
union
{ char *p;
int i;
char b;
}
main()
{
p=(char*)malloc(8*sizeof(char));
}

8. What is the error in the following code?
struct x{
struct{
struct{
char ch;
} x;
}};
a) Definition wrong b) Error c) Wrong syntax d) None

Post your comment