Hello I have just a few questions that I need help answering: Question 211 pts R
ID: 3865811 • Letter: H
Question
Hello I have just a few questions that I need help answering:
Question 211 pts
Review this declaration for a constructor:
Widget (int = 0, int = 0);
Which statement below correctly calls the constructor?
Given the Widget class below, which of the following statements is true?
class Widget{
Widget() {}
~Widget() {}
};
Question 351 pts
Given this code segment:
int *intPtr = new int;
which statement below properly releases the memory?
Question 401 pts
Flag this Question
Question 411 pts
Which of the following enables you to create a new class based on an existing class?
Flag this Question
Question 421 pts
Which of the following correctly compares the two strings below to see if they contain the same value?
char name1[50] = "Sam Smith";
char name2[50] = "Stan Smith";
Flag this Question
Question 431 pts
The strlen() function returns the number of ____ in its C-string parameter.
Flag this Question
Question 441 pts
What is stored in the variable name after the code below executes and the user enters John Doe at the keyboard?
char name[50];
cin >> name;
Flag this Question
Question 451 pts
Given the following array:
char greeting[80];
which of the statements below provides a value for greeting?
Flag this Question
Question 461 pts
Which of the following declarations is incorrect?
Flag this Question
Question 471 pts
The method ____ returns the next character from the input stream without extracting the character from the stream.
Flag this Question
Question 481 pts
Flag this Question
Question 491 pts
What prints as a result of the code segment below (there is a space between the two words)?
cout << strlen("Hello World");
Explanation / Answer
Q1. Widget (int = 0, int = 0);
Ans. All of the above
Q2. class Widget{
Widget() {}
~Widget() {}
};
Ans. ~Widget() will be executed automatically when an object of the Widget class goes out of scope.
Q3. int *intPtr = new int;
Ans. Delete intPtr
Q4. (Question 401 pts)
Ans. The code generates a compiler error at line 13. (because private members cannot be inherited )
Q5. Which of the following enables you to create a new class based on an existing class?
Ans. Inheritance
Q6. Which of the following correctly compares the two strings below to see if they contain the same value?
char name1[50] = "Sam Smith";
char name2[50] = "Stan Smith";
Ans. if (strcmp(name1, name2)==0)
Q7. The strlen() function returns the number of ____ in its C-string parameter.
Ans. Characters
Q8. What is stored in the variable name after the code below executes and the user enters John Doe at the keyboard?
Ans. John
Q9. Given the following array:
char greeting[80];
which of the statements below provides a value for greeting?
Ans. strcpy (greeting, "hello");
Q10. Which of the following declarations is incorrect?
Ans. All of the above declarations are correct, but (char *greeting = "hello"; this may give a warning)
Q11. The method ____ returns the next character from the input stream without extracting the character from the stream.
Ans. cin.peek()
Q12. Which of the following statements is true with respect to the code fragment below?
Ans. The code will print "The strings are not equal".
Q13. What prints as a result of the code segment below (there is a space between the two words)?
cout << strlen("Hello World");
Ans. 11
Please feel free to comment if explanation is required anywhere. Thank you!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.