C++_16.9.2018 40 MARKS 40 MIN https://tinyurl.com/ya62ayzs 1) Declaration of a pointer more than once may cause A. Error B. Abort C. Trap D. Null 2Whice is not a correct variable type in C++? A. float B. real C. int D. double 3. Which operation is used as Logical 'AND' A. Operator-& B. Operator- C. Operator-&&D. Operator + 4 An expression A.B in C++ means A. A is member of object B B. B is member of Object A C. Productof A and B D. None of these 5 A C++ code line ends with A. A Semicolon (;) B. A Fullstop(.) C. A Comma (,) D. A Slash (/) 6 function is used to allocate space for array in memory. A. malloc() B. realloc() C. alloc() D. calloc() 7 A pointer pointing to a variable that is not initialized is called A. Void Pointer B. Null Pointer C. Empty Pointer D. Wild Pointer
8 Default constructor has arguments. A. No argument B. One Argument C. Two Argument D. None of these 9 A class whos objects can not be created is known as A. Absurd Class B. Dead Class C. Super Class D. Abstract Class 10 Which class allows only one object to be created. A. Nuclear Family Class B. Abstruct Class C. Sigleton Class D. Numero Uno Class 11 Reusability of code in C++ is achieved through A. Polymorphism B. Inheritance C. Encapsulation D. Both A and B 12In CPP, members of a class are by default. A. Public B. Private C. protected D. Static 13In C++ Program, inline fuctions are expanded during A. Run Time B. Compile Time C. Debug Time D. Coding Time 14To perfor file input / output operation in C++, we must include which header file? A. <fiostream> B. <ifstream> C. <ofstream> D. <fstream>
15 An exceptio in C++ can be generated using which keywords. A. thrown B. threw C. throw D. throws Consider the following program: #include <iostream> #include <string> using namespace std; int main () string str = "This*is^a.45min test."; int i; for (i = 0; i < str.length( ); i++) if (ispunct(str[i])) str[i] = ; // a blank str[i] = tolower (str[i]); cout << str; 16 What is printed by the last line of the code? A. this*is^a.45min test. B. thisisa45mintest C. this is a 45min test D. this is a 45min test. 17 What is cout? A. It is a function B. It is an operator C. It is a class D. It is an object (class instance) E. It is a reserved word (C++ keyword) 18 Given below are some statements about the default (0- argument) constructor: I. Its return type is the type of the class II. It has no return type III. The programmer can define it, but the C++ language doesn t require this IV. The programmer must define it V. It is always defined by C++ if it isn t provided by the programmer
VI. It is sometimes, but not always, defined by C++ if it isn t provided by the programmer Which of these statements are true? A. I, III and V only B. I, II and VI only C. II and IV only D.II, III and V only E. II, III and VI only 19Which of the following functions will correctly return True if its argument is an odd integer? I. bool IsOdd (int x) return (x % 2 == 1); II. bool IsOdd (int x) return (x / 2 == 1); III. bool IsOdd (int x) if (x % 2 == 1) return true; else return false; A. II only B. I and II only C. I and III only D. II and III only E. I, II and III 20 When an ADT is implemented as a C++ class, which of the following should normally be true? A. Member functions are private, member variables are public
B. Member functions are public, member variables are private C. Member functions as well as member variables are private D. Member functions as well as member variables are public 21. If the class name is X, what is the type of its this pointer (in a nonstatic, non-const member function)? a. const X* const b. X* const c. X* d. X&* 22. Which classes allow primitive types to be accessed as objects? a. Storage b. Virtual c. Friend d. Wrapper
23. When is std::bad_alloc exception thrown? a. When new operator cannot allocate memory b. When alloc function fails c. When type requested for new operation is considered bad, this exception is thrown d. When delete operator cannot delete the allocated (corrupted) object 24. Which one of the following is not a fundamental data type in C++ a. float b. string c. int d. wchar_t 25. Which of the following is a valid destructor of the class name Country a. int ~Country()
b. void Country() c. int ~Country(Country obj) d. void ~Country() 26. Which of the following correctly describes C++ language? a. Statically typed language b. Dynamically typed language c. Both Statically and dynamically typed language d. Type-less language 27. Which of the following keyword supports dynamic method resolution? a. abstract b. Virtual c. Dynamic d. Typeid
28. Which of the following is the most preferred way of throwing and handling exceptions? a. Throw by value and catch by reference. b. Throw by reference and catch by reference. c. Throw by value and catch by value d. Throw the pointer value and provide catch for the pointer type. 29. Which of the following is not true about preprocessor directives a. They begin with a hash symbol b. They are processed by a preprocessor c. They form an integral part of the code d. They have to end with a semi colon 30. What s wrong? while( (i < 10) && (i > 24)) a. the logical operator && cannot be used in a test condition
b. the while loop is an exit-condition loop c. the test condition is always false d. the test condition is always true 31 In the following function: int f (int n) int v; v = 2*n+1; return v; What is the storage class of variable v? A. static B. dynamic C. contextual D. automatic E. inline 32 Consider this piece of code: void mysterious(int i, int &k) i = 1; k = 2; int main () int x = 0; mysterious (x, x); cout << x << endl; return 0; What is the value of x that gets printed by the main? A. 0 B. 1 C. 2 D. None of these 33 Consider the following class: class FooBar public: void f1 (string s); void f2 (const string &s); void f3 (string s) const; private: string str; ; Which of the three member functions could legally alter
member variable str? A. The function f1 only B. The function f2 only C. The function f3 only D. Two of them E. All three of them 34 The output of this program is int main () cout << Hello World! return 0; a. Hello World b. Syntax error c. 0 d. Hello World! 35 Observe following program and answer class Example public: int a,b,c; Example()a=b=c=1; //Constructor 1 Example(int a)a = a; b = c = 1; //Constructor 2 Example(int a,int b)a = a; b = b; c = 1; //Constructor 3 Example(int a,int b,int c) a = a; b = b; c = c; //Constructor 4 In the above example of constructor overloading, the following statement will call which constructor Example obj = new Example (1,2,3); a. Constructor 2 b. Constructor 4 c. Constrcutor 1 d. Type mismatch error 36 The output of this program is int a = 10; void main() int a = 20; cout << a << ::a; a. Syntax error b. 10 20 c. 20 10 d. 20 20
37 The output of int a = 5; int b = 10; cout << (a>b?a:b); a. 5 b. 10 c. Syntax error d. None of above 38What is the output of this program? #include using namespace std; int main() int a; a = 5 + 3 * 5; cout << a; return 0; A 35 B 20 C 25 D 30 39. What is the output of the program #include<iostream.h> void main() int n=1; cout<<endl<< The numbers are; <<endl; do cout <<n<< t ; n++; while (n<=100); cout <<endl; A) Print natural numbers 0 to 99 B) Print natural numbers 1 to 99
C) Print natural numbers 0 to 100 D) Print natural numbers 1 to 100 40 The keyword used to transfer control from a function back to the calling function is A. switch B. goto C. go back D. return