C++/ Java Interview Questions - Geometric

1. Find the error in the following program function?

f()
{ int a;
void c;
f2(&c,&a);}

a)Error b) No output c) void can’t be passed by reference d) None of the above

2. Answer the following questions below?
a=0;
b= (a=0)? 2:3;

a) What will be the value of b?

i) 2 ii) 3 iii) 0 iv) None of the above

b) If in first statement a=0 is replaced by a = -1, b=?

i) 2 ii) 3 iii) Error iv) None of the above

c) If in second statement a=0 is replaced by a = -1, b=?

i) 2 ii) 3 iii) Error iv) None of the above

3. Explain the statements in the given code?

char *a[2];
int const *p;
int *const p;
struct new { int a;int b; *var[5] (struct new)}

4. Find the value of c in the given function?
f()
{
int a=2;
f1(a++);
}
f1(int c)
{printf("%d", c);}

a) 2 b) Garbage value c) 3 d) None

5. What is the value of c in the given function?
f1()
{
f(3);
}
f(int t)
{
switch(t);
{
case 2: d=3;
case 3: d=4;
case 4: d=5;
case 5: d=6;
default: d=0;
}
a) 3 b) 4 c) 5 d) 0 e) 6

6. What is the error in the following program function?

int *f1()
{
int a=5;
return &a;
}
f()
int *b=f1()
int c=*b;
}

a) pointers are not correctly used
b) return statement is not used correctly
c) function is not in the main
d) function is non-executable

7. Which one is correct when a pointer to a function returns a integer pointer?

a) Function returning an int pointer
b) Function pointer returning an int pointer
c) Function pointer returning an array of integers
d) Array of function pointer returning an array of integers

8. Find the error in the following program segment?

int a;
short b;
b=a;

a) int can’t be equal to short
b) equality operator can’t be used
c) can’t convert long to short
d) None of the above

9. What is a function? What are the different arguments that a function can contain?

10. What is the character set used in JAVA 2.0?
a) Unicode b) UTF-8 c) ISO-8869-1 d) UTF-16
Post your comment