NEW
Font size
WorksheetsC++ Intermediate
Total questions: 45
Worksheet time: 4hrs 45mins
Which declaration is valid?
extern static int mVar;
auto static int mVar;
static const int mVar;
static extern int mVar;
What is the result on the console screen?
0
unknown value
compile error
runtime error
What is the result on the console screen?
0
10
unknown value
compile error
sizeof(long long) is equal to (windows 32-bits) ... byte.
8
16
32
“long long” is not valid type
Which one is NOT correct about structure?
function of structure is valid only in C++
in C, struct contents variable/const only
in C++, by default, all of struct member are public
in C, struct allow single inheritance only
What is the result on the console screen?
0
10
unknown value
runtime error
Value of FALL is:
0
3
17
0x100
What is the result on the console screen?
0 0 2
0 0 3
1 1 3
compile error
What is the result on the console screen?
0 1
1 2
1 1
compile error
What is the result on the console screen?
1 1 2
1
1 1 1
compile error
Value of B is ...
128
-128
0
1
What is the result on the console screen?
0
0.4
else
compile error
A function prototype are useful:
Because they tell the compiler that a function is implemented later
Because they make the program more readable
Because they allow the programmer to see a quick list of functions in the program along with the arguments for each of function
All of other answers are correct
Which library does “printf” belong to?
iostream
cstdio
conio.h
assert.h
What is the result on the console screen? (windows 32 bits)?
1
5
6
4
What is the result on the console screen? (windows 32 bits)?
1
5
6
4
What is the problem of the code above?
cannot assign char *p = (char*)arr;
cause memory leak
runtime error
no problem
What is the problem of the code above?
cannot assign char *p2 = (char*)p;
memory leak
runtime error
no problem
What is the problem of the code above?
cannot assign a[0] = 10;
cannot declare void Todo(void *a)
cannot call Todo(&a)
no problem
What is the value of a[1][1]?
2
4
5
0
What is value of *(p+5)
6
0
random value
compile error
What is the problem of the code above?
runtime error
Memory leak. Lack of “delete q” at the end.
Memory leak. Lacking of “delete q” before set q = p;
no problem
What is the result on the console screen?
hello
h
runtime error
compile error
What is the result on the console screen?
0
1
runtime error
compile error
What is the result on the console screen?
1 2
2 2
runtime error
compile error
What is the result on the console screen?
random value
10
runtime error
compile error
Value of p is:
0xff000000
0xff000010
10
unknown
Value of p is:
0xff000010
0
100
unknown
Value of iVar is:
5
10
11
runtime error
What is the result on the console screen?
0
1
random value
compile error
What is the result on the console screen?
Base
Derive
Derive
Base
Derive
Base
What is the result on the console screen?
Base
Derive
Derive
Base
Derive
Base
What is the result on the console screen?
Base
Derive
Derive
Base
Derive
Base
What is the result on the console screen?
Base
Derive
Derive
Base
Derive
Base
What is the result on the console screen?
Base1
Base2
Derive
Base1
Base1
Base2
Derive
Derive
Base1
Base2
Derive
Base2
Base1
What is the result on the console screen?
Init
Destroy
Init
Destroy
Nothing is printed in console screen
What is the result on the console screen?
0
1
random value
runtime time
What is the result on the console screen?
init
init
destroy
runtime error
compile error
What is the result on the console screen?
0
10
random value
compile error
What is value of sizeof(MyStruct) (4 bytes alignment)
7
8
10
12
Which saying below is correct?
Value of B is equal to value of A
Cannot set Derive*B = (Derive*)A;
Value of B->m_iVal is zero
B is NULL (0
What is the result on the console screen?
init
destroy
init
destroy
nothing is printed in screen
Which saying is correct?
This causes memory leak, MUST insert “delete p” before “return p”;
This causes memory leak, MUST insert “delete p” after “return p”;
This causes memory leak, MUST insert “delete q” after using q in main()
This code is OK.
What is the result on the console screen?
Destroy 0
Destroy 1
Destroy 0
Destroy 1
nothing is printed in screen
What is value of *i (little endian)
1
0x01000000
0x10000000
compile error
