0 votes
in JAVA by (30.8k points)
What do you mean by nameless objects?

i) An object created by using the new keyword.

ii) An object of a superclass created in the subclass.

iii) An object without having any name but having a reference.

iv) An object that has no reference.

1 Answer

0 votes
by (19.9k points)

An object that has no reference.

Explanation: The nameless objects are basically referred to as anonymous objects. The anonymous objects do not have any names. We can also say that, when an object is initialized but is not assigned to any reference variable, it is called an anonymous object. For example, new Employee();.

If we assign it to a reference variable like,

Employee emp = new Employee();

In the above code, emp is a reference variable. Therefore, the above object is not anonymous, as it is assigned to a reference variable.

Hence, the correct answer is option (iv).

Related questions