wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

C++ Intermediate

Total questions: 45

Worksheet time: 4hrs 45mins

Name
Class
Date
1.

Which declaration is valid?

a)

extern static int mVar;

b)

auto static int mVar;

c)

static const int mVar;

d)

static extern int mVar;

2.

What is the result on the console screen?

a)

0

b)

unknown value

c)

compile error

d)

runtime error

3.

What is the result on the console screen?

a)

0

b)

10

c)

unknown value

d)

compile error

4.

sizeof(long long) is equal to (windows 32-bits) ... byte.

a)

8

b)

16

c)

32

d)

“long long” is not valid type

5.

Which one is NOT correct about structure?

a)

function of structure is valid only in C++

b)

in C, struct contents variable/const only

c)

in C++, by default, all of struct member are public

d)

in C, struct allow single inheritance only

6.

What is the result on the console screen?

a)

0

b)

10

c)

unknown value

d)

runtime error

7.

Value of FALL is:

a)

0

b)

3

c)

17

d)

0x100

8.

What is the result on the console screen?

a)

0 0 2

b)

0 0 3

c)

1 1 3

d)

compile error

9.

What is the result on the console screen?

a)

0 1

b)

1 2

c)

1 1

d)

compile error

10.

What is the result on the console screen?

a)

1 1 2

b)

1

c)

1 1 1

d)

compile error

11.

Value of B is ...

a)

128

b)

-128

c)

0

d)

1

12.

What is the result on the console screen?

a)

0

b)

0.4

c)

else

d)

compile error

13.

A function prototype are useful:

a)

Because they tell the compiler that a function is implemented later

b)

Because they make the program more readable

c)

Because they allow the programmer to see a quick list of functions in the program along with the arguments for each of function

d)

All of other answers are correct

14.

Which library does “printf” belong to?

a)

iostream

b)

cstdio

c)

conio.h

d)

assert.h

15.

What is the result on the console screen? (windows 32 bits)?

a)

1

b)

5

c)

6

d)

4

16.

What is the result on the console screen? (windows 32 bits)?

a)

1

b)

5

c)

6

d)

4

17.

What is the problem of the code above?

a)

cannot assign char *p = (char*)arr;

b)

cause memory leak

c)

runtime error

d)

no problem

18.

What is the problem of the code above?

a)

cannot assign char *p2 = (char*)p;

b)

memory leak

c)

runtime error

d)

no problem

19.

What is the problem of the code above?

a)

cannot assign a[0] = 10;

b)

cannot declare void Todo(void *a)

c)

cannot call Todo(&a)

d)

no problem

20.

What is the value of a[1][1]?

a)

2

b)

4

c)

5

d)

0

21.

What is value of *(p+5)

a)

6

b)

0

c)

random value

d)

compile error

22.

What is the problem of the code above?

a)

runtime error

b)

Memory leak. Lack of “delete q” at the end.

c)

Memory leak. Lacking of “delete q” before set q = p;

d)

no problem

23.

What is the result on the console screen?

a)

hello

b)

h

c)

runtime error

d)

compile error

24.

What is the result on the console screen?

a)

0

b)

1

c)

runtime error

d)

compile error

25.

What is the result on the console screen?

a)

1 2

b)

2 2

c)

runtime error

d)

compile error

26.

What is the result on the console screen?

a)

random value

b)

10

c)

runtime error

d)

compile error

27.

Value of p is:

a)

0xff000000

b)

0xff000010

c)

10

d)

unknown

28.

Value of p is:

a)

0xff000010

b)

0

c)

100

d)

unknown

29.

Value of iVar is:

a)

5

b)

10

c)

11

d)

runtime error

30.

What is the result on the console screen?

a)

0

b)

1

c)

random value

d)

compile error

31.

What is the result on the console screen?

a)

Base

Derive

b)

Derive

Base

c)

Derive

d)

Base

32.

What is the result on the console screen?

a)

Base

Derive

b)

Derive

Base

c)

Derive

d)

Base

33.

What is the result on the console screen?

a)

Base

Derive

b)

Derive

Base

c)

Derive

d)

Base

34.

What is the result on the console screen?

a)

Base

Derive

b)

Derive

Base

c)

Derive

d)

Base

35.

What is the result on the console screen?

a)

Base1

Base2

Derive

b)

Base1

Base1

Base2

Derive

c)

Derive

Base1

Base2

d)

Derive

Base2

Base1

36.

What is the result on the console screen?

a)

Init

Destroy

b)

Init

c)

Destroy

d)

Nothing is printed in console screen

37.

What is the result on the console screen?

a)

0

b)

1

c)

random value

d)

runtime time

38.

What is the result on the console screen?

a)

init

b)

init

destroy

c)

runtime error

d)

compile error

39.

What is the result on the console screen?

a)

0

b)

10

c)

random value

d)

compile error

40.

What is value of sizeof(MyStruct) (4 bytes alignment)

a)

7

b)

8

c)

10

d)

12

41.

Which saying below is correct?

a)

Value of B is equal to value of A

b)

Cannot set Derive*B = (Derive*)A;

c)

Value of B->m_iVal is zero

d)

B is NULL (0

42.

What is the result on the console screen?

a)

init

b)

destroy

c)

init

destroy

d)

nothing is printed in screen

43.

Which saying is correct?

a)

This causes memory leak, MUST insert “delete p” before “return p”;

b)

This causes memory leak, MUST insert “delete p” after “return p”;

c)

This causes memory leak, MUST insert “delete q” after using q in main()

d)

This code is OK.

44.

What is the result on the console screen?

a)

Destroy 0

b)

Destroy 1

c)

Destroy 0

Destroy 1

d)

nothing is printed in screen

45.

What is value of *i (little endian)

a)

1

b)

0x01000000

c)

0x10000000

d)

compile error