Discussion
In object oriented programming for references and values, which of the following statements are true :
(i) If variables are references, then every object must be created explicitly.
(ii) If variables are values, then object creation can happen implicitly as result.
(iii) If variables are references, then every object must be created implicitly
(iv) If variables are values, then object creation happens explicitly
Answer: A
The true statements are (i) and (ii).
With reference semantics, as in Java, a variable holds only a reference. Declaring it creates no object, so every object must be created explicitly, for example with new (i).
With value semantics, as for C++ objects declared as local variables, the variable is the object itself. Declaring it, passing it by value or returning it creates an object implicitly (ii).
Statements (iii) and (iv) reverse these two rules, so every option including them is wrong.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development