OOPS

August 29, 2024

OOPS

August 29, 2024

OOPS

August 29, 2024

OOPS

August 29, 2024

OOPS

Question 93
What is the right way to declare a copy constructor of a class if the name of the class is MyClass?
A
MyClass (constant MyClass *arg)
B
MyClass (constant MyClass &arg)
C
MyClass (MyClass arg)
D
MyClass (MyClass *arg)
Question 93 Explanation: 
→Copy Constructor is a type of constructor which is used to create a copy of an already existing object of a class type.
→Declaration of copy constructor syntax is different from c++ to java.
→In C++, It is usually of the form class-name (Class_name &vn),
→In Java, the syntax is Class_name(class_name vn).
→So w.r.to C++ , option (B) is correct and w.r.to Java option (c ) is correct.
Correct Answer: B
Question 93 Explanation: 
→Copy Constructor is a type of constructor which is used to create a copy of an already existing object of a class type.
→Declaration of copy constructor syntax is different from c++ to java.
→In C++, It is usually of the form class-name (Class_name &vn),
→In Java, the syntax is Class_name(class_name vn).
→So w.r.to C++ , option (B) is correct and w.r.to Java option (c ) is correct.

Leave a Reply

Your email address will not be published. Required fields are marked *