adplus-dvertising
frame-decoration

Question

Which among the following is correct for the class defined below?
class student
{
 int marks;
 public: student(){}
 student(int x)
 { 
  marks=x; 
 }
};
main()
{
student s1(100);
student s2();
student s3=100;
return 0;

a.

Object s3, syntax error

b.

Only object s1 and s2 will be created

c.

Program runs and all objects are created

d.

Program will give compile time error

Answer: (c).Program runs and all objects are created

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Which among the following is correct for the class defined below?
Riya : June 26, 2023

Ans btao?
Mko

Similar Questions

Discover Related MCQs

Q. For constructor overloading, each constructor must differ in ___________ and __________

Q. How many types of constructors are available, in general, in any language?

Q. Which constructor is called while assigning some object with another?

Q. It’s necessary to pass object by reference in copy constructor because:

Q. Which specifier applies only to the constructors?

Q. Which among the following is true?

Q. Which type of constructor can’t have a return type?

Q. Why do we use static constructors?

Q. When and how many times a static constructor is called?

Q. Which among the following is true for static constructor?

Q. Within a class, only one static constructor can be created.

Q. Default constructor initializes all data members as:

Q. When is the static constructor called?

Q. If constructors of a class are defined in private access, then:

Q. Copy constructor is a constructor which ________________

Q. The copy constructor can be used to:

Q. If two classes have exactly same data members and member function and only they differ by class name. Can copy constructor be used to initialize one class object with another class object?

Q. The copy constructors can be used to ________

Q. Which returning an object, we can use ____________

Q. If programmer doesn’t define any copy constructor then _____________