Aspire's Library

A Place for Latest Exam wise Questions, Videos, Previous Year Papers,
Study Stuff for MCA Examinations - NIMCET

Previous Year Question (PYQs)



Which of the following is correct using the constructor?

A. string s1;

B. string s2(s1);

C. string s3{7};

D. string s4{'a'};

E. string s5{7,'a'};
Choose the most appropriate answer from the options given below:






Solution

A is valid because it calls the default constructor.
B is valid because it calls the copy constructor.
C is not valid as a normal string constructor form.
D is valid because it initializes the string using character value.
E is valid because it initializes string with count and character.
So, correct option is:
$\boxed{(a)\ \text{A, B, D, E only}}$


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More

Ask Your Question or Put Your Review.

loading...