0% found this document useful (0 votes)
155 views

Cplusplus Mock Test III

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
155 views

Cplusplus Mock Test III

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

C++ MOCK TEST

http://www.tutorialspoint.com Copyright © tutorialspoint.com

This section presents you various set of Mock Tests related to C++ Framework. You can
download these sample mock tests at your local machine and solve offline at your convenience.
Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.

C++ MOCK TEST III

Q 1 - Choose the option not applicable for the constructor.

A - Cannot be called explicitly.

B - Cannot be overloaded.

C - Cannot be overridden.

D - None of the above.

Q 2 - An array can be passed to the function with call by value mechanism.

A - True

B - False

Q 3 - A C++ program statements can be commented using

A - Single line comment

B - Multi line comment

C - Either a or b

D - Both a and b.

Q 4 - HAS-A relationship between the classes is shown through.

A - Inheritance

B - Container classes

C - Polymorphism

D - None of the above.


Q 5 - What is a generic class.

A - Function template

B - Class template

B - Inherited class

B - None of the above.

Q 6 - What is the full form of STL?

A - Standard template library.

B - System template library.

C - Standard topics library.

D - None of the above.

Q 7 - Which type of data file is analogous to an audio cassette tape?

A - Random access file

B - Sequential access file

C - Binary file

D - Source code file

Q 8 - i) single file can be opened by several streams simultaneously.

ii) several files simultaneously can be opened by a single stream

A - i and ii are true

B - i and ii are false

C - Only i is true

D - Only ii is true

Q 9 - With respective to streams >> operator is called as

A - Insertion operator

B - Extraction operator

C - Right shift operator

D - Left shift operator

Q 10 - i ‘ios’ is the base class of ‘istream’

ii All the files are classified into only 2 types. 1 Text Files 2 Binary Files.
A - Only i is true

B - Only ii is true

C - Both i & ii are true

D - Both i & ii are false

Q 11 - An exception is __

A - Runtime error

B - Compile time error

C - Logical error

D - None of the above

Q 12 - i) Exception handling technically provides multi branching.

ii) Exception handling can be mimicked using ‘goto’ construct.

A - Only i is true

B - Only ii is true

C - Both i & ii are true

D - Both i && ii are false

Q 13 - What is the output of the following program?

#include<isotream>

using namespace std;


main()
{
const int a = 5;

a++;
cout<<a;
}

A-5

B-6

C - Runtime error

D - Compile error

Q 14 - What is the output of the following program?

#include<isotream>

using namespace std;


main()
{
char s[] = "hello", t[] = "hello";
if(s==t)
cout<<"eqaul strings";
}

A - Equal strings

B - Unequal strings

C - No output

D - Compilation error

Q 15 - What is the outpout of the following program?

#include<isotream>

using namespace std;


main()
{
enum {
india, is = 7, GREAT
};

cout<<india<<” “<<GREAT;
}

A-01

B-02

C-08

D - Compile error

Q 16 - What is the output of the following program?

#include<isotream>

using namespace std;


main()
{
short unsigned int i = 0;

cout<<i--;
}

A-0

B - Compile error

C - 65535

D - 32767

Q 17 - What is the output of the following program?

#include<isotream>

using namespace std;


main()
{
int x = 5;
if(x==5)
{
if(x==5) break;
cout<<"Hello";
}

cout<<”Hi”;
}

A - Compile error

B - Hi

C - HelloHi

D - Hello

Q 18 - What is the output of the following program?

#include<isotream>

using namespace std;


void f() {
static int i;

++i;
cout<<i<<” “;
}
main()
{
f();
f();
f();
}

A-111

B-000

C-321

D-123

Q 19 - What is the output of the following program?

#include<isotream>

using namespace std;


void f() {
cout<<”Hello”<<endl;
}
main()
{
}

A - No output

B - Error, as the function is not called.

C - Error, as the function is defined without its declaration

D - Error, as the main function is left empty


Q 20 - What is the output of the following program?

#include<isotream>

using namespace std;


main()
{
int x = 1;

switch(x)
{
default: cout<<”Hello”;
case 1: cout<<”Hi”; break;
}
}

A - Hello

B - Hi

C - HelloHi

D - Compile error

Q 21 - What is the output of the following program?

#include<isotream>

using namespace std;


void swap(int m, int n)
{
int x = m;

m = n;
n = x;
}
main()
{
int x = 5, y = 3;

swap(x,y);
cout<<x<<” “<<y;
}

A-35

B-53

C-55

D - Compile error

Q 22 - What will be the output of the following program?

#include<isotream>
#include<string.h>

using namespace std;


main()
{
cout<<strcmp("strcmp()","strcmp()");
}

A-0

B-1

C - -1

D - Invalid use of strcmp function

Q 23 - What is the output of the following program?

#include<isotream>

using namespace std;


main()
{
int r, x = 2;

float y = 5;

r = y%x;
cout<<r;
}

A-1

B-0

C-2

D - Compile error

Q 24 - What is the size of the following union definition?

#include<isotream>

using namespace std;


main()
{
union abc {
char a, b, c, d, e, f, g, h;

int i;
};
cout<<sizeof(abc);
}

A-1

B-2

C-4

D-8

Q 25 - What is the size of ‘int’?

A-2

B-4
C-8

D - Compiler dependent

ANSWER SHEET

Question Number Answer Key

1 C

2 B

3 D

4 B

5 B

6 A

7 B

8 C

9 B

10 C

11 A

12 A

13 D

14 C

15 C

16 A

17 A

18 D

19 A

20 B

21 B

22 A

23 D

24 C

25 D

Loading [MathJax]/jax/output/HTML-CSS/jax.js

You might also like