Java OOP | Sololearn: Learn to code for FREE!


Java OOP

I need a deeply explaining about object type and reference type.. Actually I,m confusing


3/11/2020 8:16:33 PM

Baha-din Mohammed

1 Answer

New Answer


In Java, for example : ClassName ref; ref is called now reference variable of ClassName type. Now it not still assigned so points null or garbage value. ClassName ref=new ClassName() ; Now ref reference variable is allocated some memory so now we can say ref is called an object of ClassName. Reference means making a alias name in stock memory.. Object is allocated memory pointed by the referencce variable.. So simply, Class a; Class b; a, b are reference variables may or may not point to storage locations. Can be reassigned to other references like a=b. a=new Class() ; b=new Class() ; Now a, b are called objects points to some memory in object pool. So objects are allocated memory's.. Hoping this helps you..