Prog2 _Lab Exam

advertisement
Lab Exam OOP C++ ) ‫( تجسير‬
Student Name:-------------------------------
ID:---------------------
Q1: Which of the following is not a valid C++ identifier?
a.
b.
c.
d.
my Value
_AAA1
width
m_x
Q2: Which of the following is a variable declaration statement?
a. int total;
b. #include <iostream>
c. int main()
d. // first string entered by user
Q3: What is the value of result after the following C++ statements execute?
int a, b, c, d, result;
a = 4;
b = 12; c = 37;
d = 51;
result = d % a * c + a % b + a;
a. 119
b. 51
c. 127
d. 59
Q4: Attributes of a class are also known as:
a.
b.
c.
d.
Constructors.
Local variables.
Data members.
Classes.
Q5: A default constructor has how many parameters?
a.
b.
c.
d.
0.
1.
2.
Variable number.
Q6: A constructor can specify the return type:
a. int.
1
b. string.
c. void.
d. A constructor cannot specify a return type.
Q7: To execute multiple statements when an if statement’s condition is true, enclose
those statements in a pair of:
a.
b.
c.
d.
Parentheses, ( ).
Square Brackets, [ ].
Braces, { }.
Angle brackets, < >.
Q8 :Which of the following does not display correct if answer is equal to 7 and
incorrect if answer is not equal to 7?
a. if ( answer != 7 )
cout << "correct";
else
cout << "incorrect";
b. cout << answer == 7 ? "correct" : "incorrect";
c. cout << answer != 7 ? "correct" : "incorrect" ;
d. answer == 7 ? cout << "correct" : cout << "incorrect";
Q9 : Write a function to determine the minimum value between two float variables?
Q10 : Write a function to determine the average value of n float values?
2
Download