Which of the following statements are true? Object names are like array names. O
ID: 3698360 • Letter: W
Question
Which of the following statements are true?
Object names are like array names. Once an object name is declared, it references to an object.
An object name is a constant, though the contents of the object may change.
An object is associated with only one object name.
Object names cannot be reassigned to reference another object.
Which of the following statements are true?
Circle circle = Circle(5) should be replaced by Circle circle(5).
The statement Circle circle = Circle(5) creates a Circle object with radius 5 and copies its contents to circle.
Circle circle = Circle() should be replaced by Circle circle.
The statement Circle circle = Circle() creates a Circle object using the no-arg constructor and copies its contents to circle.
Show the output of the following code:
#include <iostream>
using namespace std;
class A
{
public:
int x;
int y;
int z;
A(): x(1), y(2), z(3)
{
}
};
int main()
{
A a;
cout << a.x << " " << a.y << " " << a.z;
return 0;
}
3 3 3
1 2 3
2 2 2
1 1 1
1 1 2
Object names are like array names. Once an object name is declared, it references to an object.
An object name is a constant, though the contents of the object may change.
An object is associated with only one object name.
Object names cannot be reassigned to reference another object.
Which of the following statements are true?
Circle circle = Circle(5) should be replaced by Circle circle(5).
The statement Circle circle = Circle(5) creates a Circle object with radius 5 and copies its contents to circle.
Circle circle = Circle() should be replaced by Circle circle.
The statement Circle circle = Circle() creates a Circle object using the no-arg constructor and copies its contents to circle.
Show the output of the following code:
#include <iostream>
using namespace std;
class A
{
public:
int x;
int y;
int z;
A(): x(1), y(2), z(3)
{
}
};
int main()
{
A a;
cout << a.x << " " << a.y << " " << a.z;
return 0;
}
3 3 3
1 2 3
2 2 2
1 1 1
1 1 2
Explanation / Answer
1.An object name is constant,though the contents of the object may change.Because for a class we can create object,using that object we can perforn different methods what we have in the class.
2.Circle circle=Circle() creates a Cirlce object with no-arg constructor and copies its contents to circle is true,because here we can create object for the class Circle so that Circle object can access all contents of class Circle.
3.Output:1 2 3
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.