C++/ Java Interview Questions - Polaris

1. What is the output of the following program?
void main( )
{
int i;
i=(2,3);
cout<}
a) 2 b) 3 c) Garbage value. d) none of these.

2. What is the output of the following program?
void main( )
{
int i;
for(i=0;i++;i<100)
cout<}

a) 10 b) 0 c) Error d) Infinite

3. What is the output of the following program?
void main( )
{
char c[ ]="cdef";
cout<}

a) 5 4 b) 2 5 c) 4 5 d) none of these

4.Where Local Variables are stored ____________?
a) Stack b) Queue c) Register d) All the above.

5. Where Register variables are stored _________?
a) Heap b) CPU Register c) Memory d) None

6. Where Program code is stored _______________?
a) Heap b) CPU Register c) Memory d) None

7. What is the output of the following program?
main()
{
char *p;
cout<}
a) 1 4 b) 1 2 c) 3 4 d) 5 6

8. What is the output of the following program?
main()
{
int i=3;
switch(i)
{
default:cout<<"zero";
case 1: cout"one";
break;
case 2:cout<<"two";
break;
case 3: cout<<"three";
break;
}
}

a) zero b) three c) two d) None of these

9. What is the output of the following program?
main()
{
printf("%x",-1<<4);}

a) fff0 b) ffff c) 00ff d) 0f0f

10. What is the output of the following program?
main()
{
char string[]="Hello World";
display(string);
}
void display(char *string)
{
cout<}

a) Hello World b) string c) Compiler error d) None of these

11. What is ResourceBundle class?
12. Why there is no concept of global variables in Java?
13. What is the difference between while and do while statement?
Post your comment