Tuesday, September 6, 2011

wipro old papers

1) If you have "int main(int argc, char* argv[])" and invoke your program this way:
prog.exe a.out -i 2 -g -x 3 4
What will be the value of argc?
a) 0
b) a.out
c) 2
d) 3
e) 7
f) Other
g) I don't know


2) If n=3, what will be the result of:
switch(n) { 
case '3':
   cout << "wow \n"; break;
case 3:   cout << "bab \n"; break;
default:
   cout << "heh \n";  break;
}

a) Compiler error
b) wow
c) bab
d) heh
e) Undefined behaviour
f) I don't know


3) Which header file you should include for C++ file I/O?a) fileio
b) ifstream
c) iostream
d) fstream
e) Other
f) I don't know
What is the default access permission for members in a class?a) public
b) private
c) protected
d) I don't know


5) What is the default access permission for members in a struct?a) public
b) private
c) protected
d) I don't know


6) What will be the result of:
int f(int a) { return ++a; }
int f(unsigned int a) { return --a; }
cout << f(5);

a) 5
b) 4
c) 6
d) Compiler error
e) Undefined behaviour
f) I don't know 
7.What will !((1 || 0) && 0) evaluate to?a) 1
b) 0
c) Wrong code
d) I don't know


8. If i = 5, what will be the result of:

do { 
   cout << (--i)-- << " ";
} while(i>=2 && i < 5); 

a) Compiler error
b) It won't enter the loop
c) It will loop forever
d) 4 3 2 1
e) 4 3 2
f) 4 2 1
g) 4 2
h) I don't know


9. What will be the result after running this code:
for(int i=0;i<3;i++) {   cout << i << " ";
   continue;
   cout << 7 << " ";
   break;
   for(int j=0;j<1;j++)  cout << 5 << " "; 
 } 
a) 0 1 2
b) 0 7 1 7 2 7
c) 0 7 5 1 7 5 2 7 5
d) None of these
e) I don't know
10. What will be printed on the screen after running:
 int x=65, *p = &x;
 cout << p << "__" << *p ; 

a) Compiler error
b) Program will crash
c) MemoryAddress_65
d) 65_MemoryAddress
e) Other
f) I don't know


11. In which header file is the function isalpha()?a) conio.h
b) ifstream.h
c) string.h
d) cctype.h
e) Other
f) I don't know


12. Which one is correct?a) int a; a = new int[20];
b) int a; a = new int(20);
c) int *a; a = new int[20];
d) int *a; a = new 20;
e) int *a; a = new sizeof(int*20);
f) int a; a = new sizeof(int*20);
g) I don't know 
13. How do you access the last cell of "int arr[123];"?a) arr[123]...
b) arr[124]...
c) arr[122]...
d) Other
e) I don't know


14. May the main() function be overloaded?
a) Yes
b) No
c) I don't know


15. If we have:
int f(int x) {
   if(x>2)  return x + f(--x); 
   else  return 0; 
}

What will be the resulf of: cout << f(5);
a) Program will freeze
b) 0
c) 6
d) 10
e) 12
f) Other
g) I don't know
16. If Foo is a member function of a class, which of the following uses of const is legal?a) void Foo(const Squid& a);
b) void Foo(Squid& a) const;
c) void Foo(const Squid& a) const;
d) const void Foo(const Squid& a) const;
e) All of the above
f) None of the above
g) I don't know


17. If Foo is a static function in a class, which of the following uses of const is legal?a) void Foo(Squid& const a);
b) void const Foo(Squid& a);
c) void Foo(const Squid& a);
d) void (Squid& a) const;
e) I don't know

18. Is it possible that a class does not have a name?a) Yes, but you can't have objects from it
b) Yes, and you can have objects from it
c) No
d) I don't know 





No comments:

Post a Comment