- A It defines a method called "new" that initializes variables x and y to default values of 10 each.
- B It creates a constructor named "new" with parameters _x and _y, and initializes variables x and y with the provided values.
- C It defines a default constructor that initializes variables x and y to the values of _x and _y.
- D It declares a class with default values of 10 for variables x and y, which can be accessed using the "new" method.
- Share this MCQ
Answer:
B
Share this MCQ
-
It creates a constructor named "new" with parameters
_x
and_y
, and initializes variablesx
andy
with the provided values. Explanation: In X++, the code defines a constructor named "new" with optional parameters
_x
and_y
. This constructor is used to initialize the values of the variablesx
andy
when an object of the class is created. If no values are provided, the default values of 10 are used.
Share this MCQ