C++: Answer the follwoing multiple choice questions. No need to explain. 1- Give
ID: 3698716 • Letter: C
Question
C++: Answer the follwoing multiple choice questions. No need to explain.
1- Given the following declration, what is the value of b[1][0]?
int b[ 2 ][ 2 ] = { { 1 }, {3 , 4} };
a. 0
b. 1
c. 3
d. This is an invalid declration
2- which of the following declration correctly creates a c-string that can hold the value "phonebook"?
a. char s1;
b. char s1[9];
c. char s1=10;
d. char s1[10];
3- Given the following structure definition, what is the correct way to print the person's birth year?
struct DateType{
int Day;
int Month;
int Year;
};
struct PersonType {
int age;
float weight;
DataType birthday;
};
PersonType person;
a. std::cout<< person.birthday.year;
b. std::cout<< year;
c. std::cout<< birthday.year;
d. std::cout<< peson.year;
4- what does this function do?
int something)const char * s) {
int x;
for (x = 0; *s != ''; s++)
x++;
return x;
}
a. return the c-string parameter's length
b. return the last non-null character in the c-string parameter
9. which of the following statements about seperating a class's interface and implementation is NOT true?
a. Private data members are included in the header file
b. Changes in the class's implementation will affect the client
5- Given the folliwng class and object declation, how would you print out the age and cost of virable bottle?
class Wine {
public:
Wine();
int getAge();
float getCost();
private:
int age;
float cost;
};
Wine bottle;
a. std::cout<< bottle.getAge()<
b. std::cout<< bottle.getAge<
Explanation / Answer
//if you have any query then comment below.please rate the answer
1- Given the following declration, what is the value of b[1][0]?
int b[ 2 ][ 2 ] = { { 1 }, {3 , 4} };
c. 3
2- which of the following declration correctly creates a c-string that can hold the value "phonebook"?
b. char s1[9];
3- Given the following structure definition, what is the correct way to print the person's birth year?
a. std::cout<< person.birthday.year;
4- what does this function do?
int something)const char * s) {
int x;
for (x = 0; *s != ''; s++)
x++;
return x;
}
a. return the c-string parameter's length
9. which of the following statements about seperating a class's interface and implementation is NOT true?
a. Private data members are included in the header file
5- Given the folliwng class and object declation, how would you print out the age and cost of virable bottle?
class Wine {
public:
Wine();
int getAge();
float getCost();
private:
int age;
float cost;
};
Wine bottle;
a. std::cout<< bottle.getAge()<
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.