1.

If a reference variable is declared final then _________________(a) It can never be reassigned to refer to a different object(b) It can be assigned to refer to any object anytime(c) It can never be assigned with any object(d) It can be assigned with 2 or more objects simultaneouslyI have been asked this question by my college director while I was bunking the class.The doubt is from Object Reference in division Object of Object Oriented Programming

Answer»

The correct choice is (a) It can never be reassigned to REFER to a different object

Easiest explanation - Since the VARIABLE is declared FINAL. It will have a CONSTANT value throughout the program. It can refer to only ONE object at a time. And if it was made to refer to none of the object, it would have got no use.



Discussion

No Comment Found

Related InterviewSolutions