Placement Paper - Technical- C/C++ - Grapecity

1. when should a pointer p be a reference parameter?
a. when fn. Changes p, & u want the change to affect actual pointer argument
b. when fn. Changes p, & u do not want the change to affect actual pointer argument
c. when fn. Changes *p, & u want the change to affect actual pointer argument
d. when fn. Changes *p, & u do not want the change to affect actual pointer argument
e. when pointer points to large object

2. output???
Int y=1;
Int k=2;
Int *p1;
Int *p2;
P1=&y;
P2=&k;
p1=p2;
*p1=3
*p2=4;
printf(“%d”,y);

a. 1
b. 2
c. 3
d. 4

3.when should u use a const reference paprameter ??
a. whenever the data type might be many bytes
b. whenever the data type might be many bytes, the fn. Changes the papramter within its body, & u do not want these changes to alter the actual argument
c. whenever the data type might be many bytes, the fn. Changes the papramter within its body, & u DO want these changes to alter the actual argument
d. whenevr the data type might be many bytes , & the function does not change the parameter within it body

 

4. A is a class & B is a new class derived from A
A a;
B b;
Bb1;
B b2;

4. what c++ syntax is used to declare that a class B is derived from Class A”
a. class A derives B {……};
b. class B: public A {,……..};

5. using the variable , which is legat?
a. a=b;
b. b=a;
c. b1=b2;
d. both a & b are legal but not c;
e. both a & c are legal but not b;
f. both b & c are legal , but not a;

6. suppose there  ar e 2 fns. F has an argument of type A and g has an argument of type                         B. Which is correct?
a. both f(a) & g(a) are legal fn. Calls
b. f(a) is legal , but g(a) is not legal
c. f(a) is not legal , g(a) is legal
d. neither f(a) nor g(a) is legal fn call

7. template<class Item>
void foo(Item x);

which is right way to call with integer argument I?
a. foo(i);
b. foo<int > (i);
c. foo<Item>(i);
d. foo(<int> i);
e. foo(<Item > i);

8.
9. void quiz(int w)
{
if(w>1)
{ quiz (w/2);
quiz(w/2);
}
printf(“*”);
}
how many asterisks are printed by the function call quiz(5)?
a. 3
b. 4
c. 7
d. 8

10. void test_a (int n)
{
printf(“%d”,n);
if(n>0)
test_a(n-2);
}
test_a(4)?

a . 0 2 4
c. 0 2
d. 2 4
e. 4 2
f. 4 2 0

11. char string[8]=”abcdefg”;
*string=’\0’;
printf(“%s”,string);
a. compiler error
b. run-time error
c. no o/p, but no error
d. creates bcdefg

12. char string[8]=”abcdefg”

o/p :
printf(“%s\n”,string +3);
a. abcdefg
b. abc
c. defg
d. cdefg

13. main()
{  int I=-3, j=2,k=0,m;
m=++I&&++j||++k;
printf(“\n%d%d%D”, I,j,k,m);

a. –2 3 0 1
b. –2 3 1 1
c. –2 3 1 0
d. –2 3 0 0

14. main()
{
int I;
for(;;)
{
printf(“%d”,I++)
if(I>10)
break;
}
}
a. condition in a for-loop is mudt
b. no error
c. 2 ; shud be dropped

15.void goop ( int z[]);//prototype
int x[10];
which ois the correct way to call goop
a. goop(x);
b. goop(x[]);
c. goop(x[10]);
d. goop(&x);
e. goop(&x[]);

16. int a=3,b=17;
a=b%a;
b=++a+5;
printf(“a,b);

a. 2 8
b. 2 7
c. 3  7
d. 2 8
e. none

18. how many time shello will be printed?
FILE *fp=fopen(“test.txt”,w)
Fprintf(fp,”hello”);
Fork();

a. 1
b. 2
c. 0
d. none

19. int a;
int b=0;
while(a)
{
{ a&=a-1;
b++;
}
a &b
a. 0 & 15
b. 1 & 16
c. 0 & 16
d. none


20. class A
{
public:
static int a;
A() {a=10};
};
int main()
{
A b;
Printf(“%d”,b.a);
Return 0;
}
will the program compile?
a  yes
b. no

 

 

Disclaimer: These are questions/Answers posted by various candidates over years, TutionCentral(TC) does not assume any legal liability or responsibility for the accuracy, completeness or usefulness of the information. Information provided in the site is solely intended for general guidance purpose and assumes the reader of the page full responsibility of use.


SHARE THIS
Previous Post
Next Post