https://res.cloudinary.com/hg6hswtwo/image/upload/v1/media/pics/oop_toolsandjobs_se2jyx_vudzpp
secondyear

Exception Handling MCQs In Object Oriented Programming Part 2





Exception Handling MCQs In Object Oriented Programming Part 2. Most helps in placements, competitive exams and othe university exams 2020.

Click here for Part-1

1 #include <iostream>
 using namespace std;
 int main()
 {
 int arr[] = {4, 5, 6, 7};
 int *p = (arr + 1);
 cout << *p;
 return 0;
 }
A 4
B 5
C 6
D 7

Answer B

2 #include <iostream>
 using namespace std;
 int main()
 {
 int arr[] = {4, 5, 6, 7};
 int *p = (arr + 1);
 cout << arr;
 return 0;
 }
A 4
B 5
C Address of arr
D 7

Answer C

3 #include <iostream>
 using namespace std;
 int main ()
 {
 int numbers[5];
 int * p;
 p = numbers; *p = 10;
 p++; *p = 20;
 p = &numbers[2]; *p = 30;
 p = numbers + 3; *p = 40;
 p = numbers; *(p + 4) = 50;
 for (int n = 0; n < 5; n++)
 cout << numbers[n] << ",";
 return 0;
 }
A 10,20,30,40,50,
B 1020304050
C Compile time error
D Runtime error

Answer A

4 #include <iostream>
 using namespace std;
 int main()
 {
 int arr[] = {4, 5, 6, 7};
 int *p = (arr + 1);
 cout << *arr + 9;
 return 0;
 }
A 12
B 5
C 13
D Error

Answer C

5 A void pointer cannot point to which of these?
A methods in c++
B class member in c++
C all of the mentioned
D None

Answer D

6 #include <iostream>
 using namespace std;
 int func(void *Ptr);
 int main()
 {
 char *Str = "abcdefghij";
 func(Str);
 return 0;
 }
 int func(void *Ptr)
 {
 cout << Ptr;
 return 0;
 }
A abcdefghij
B address of string “abcdefghij”
C Compile time
D Run time error

Answer B

7 #include <iostream>
 using namespace std;
 int main()
 {
 int *p;
 void *vp;
 if (vp == p);
 cout << "equal";
 return 0;
 }
A Equal
B No output
C Compile time error
D Run time error

Answer A

8 #include <iostream>
 using namespace std;
 int main()
 {
 int n = 5;
 void *p = &n;
 int *pi = static_cast<int*>(p);
 cout << *pi << endl;
 return 0;
 }
A 5
B 6
C Compile time error
D Run time error

Answer A

9 #include <iostream>
 using namespace std;
 int main()
 {
 int a = 5, c;
 void *p = &a;
 double b = 3.14;
 p = &b;
 c = a + b;
 cout << c << '\n' << p;
 return 0;
 }
A 8, memory address
B 8.14
C memory address
D None

Answer A

10 What we can‟t do on a void pointer?
A pointer arithemetic
B pointer functions
C Both
D None

Answer A

11 Which value we cannot assign to reference?
A Integer
B Floating
C Unsigned
D Null

Answer D

12 #include <iostream>
 using namespace std;
 int main()
 {
 int a = 9;
 int & aref = a;
 a++;
 cout << "The value of a is " << aref;
 return 0;
 }
A 9
B 10
C 11
D Error

Answer B

13 #include <iostream>
 using namespace std;
 void print (char * a)
 {
 cout << a << endl;
 }
 int main ()
 {
 const char * a = "Hello world";
 print(const_cast<char *> (a) );
 return 0;
 }
A Hello world
B Hello
C World
D Compile time error

Answer A

14 Identify the correct sentence regarding inequality between reference and pointer.
A we can not create the array of reference.
B we can create the Array of reference.
C we can use reference to reference.
D None

Answer A

15 Which is used to tell the computer that where a pointer is pointing to?
A Dereference
B Reference
C heap operations
D None

Answer A

16 #include <iostream>
 using namespace std;
 int main()
 {
 int x;
 int *p;
 x = 5;
 p = &x;
 cout << *p;
 return 0;
 }
A 5
B 10
C Memory address
D None

Answer A
 
17 #include <iostream>
 using namespace std;
 int main() 
 {
 int x = 9;
 int* p = &x;
 cout << sizeof(p);
 return 0;
 }
A 4
B 2
C Depends on compiler
D None

Answer C
 
18 #include <iostream>
 using namespace std;
 int main()
 {
 double arr[] = {5.0, 6.0, 7.0, 8.0};
 double *p = (arr+2);
 cout << *p << endl;
 cout << arr << endl;
 cout << *(arr+3) << endl;
 cout << *(arr) << endl;
 cout << *arr+9 << endl;
 return 0;
 }
A 7
 0xbf99fc98
 8
 5
 14
B 7
 8
 0xbf99fc98
 5
 14
C 0xbf99fc98
D None

Answer A
 
19 What does the dereference operator will return?
A rvalue equivalent to the value at the pointer address.
B lvalue equivalent to the value at the pointer address.
C it will return nothing
D None

Answer B 

20 Which operator is used in pointer to member function?
A .*
B ->*
C Both a &b
D None

Answer C

21 #include <iostream>
 using namespace std;
 class Foo
 {
 public:
 Foo(int i = 0){ _i = i;}
 void f()
 {
 cout << "Executed"<<endl;
 }
 private:
 int _i;
 };
 int main()
 {
 Foo *p = 0;
 p -> f();
 }
A Executed
B Error
C Run time error
D None

Answer A

22 Which is the best design choice for using pointer to member function?
A Interface
B Class
C Structure
D None

Answer A

23 Virtual functions allow you to
A create an array of type pointer-to-base class that can hold pointers to derived classes.
B create functions that can never be accessed.
C group objects of different classes so they can all be accessed by the same function code.
D use the same function call to execute member functions of objects from different classes.

Answer D

24 A pointer to a base class can point to objects of a derived class.
A TRUE
B FALSE

Answer A

25 A pure virtual function is a virtual function that
A causes its class to be abstract.
B returns nothing.
C is used in a base class.
D A and C

Answer D

26 An abstract class is useful when
A no classes should be derived from it.
B there are multiple paths from one derived class to another.
C no objects should be instantiated from it.
D you want to defer the declaration of the class.

Answer C

27 A friendfunction can access a class‟s private data without being a member of the class.
A TRUE
B FALSE

Answer A

28 A friend function can be used to
A mediate arguments between classes.
B increase the versatility of an overloaded operator.
C allow access to an unrelated class.
D B and C

Answer D

29 The keyword friend appears in
A the class allowing access to another class.
B the private section of a class.
C the public section of a class.
D All of the above

Answer D

30 A static function
A should be called when an object is destroyed.
B is closely connected to an individual object of a class.
C can be called using the class name and function name.
D is used when a dummy object must be created.

Answer C





Publish Your Great Work

Touch below

Your AD here