Vishal Hegde wrote:can anybody please specify a simple example of how are objects declared and reference variables declared
let us take very simple example. when you write
Here new A() creates an object of A, puts it on heap. mind that you can create multiple objects of class A and they all will be allocated different address in heap. Whenever you create an object of class, it will have its own copy of class members (this is what Rakesh meant). To make use of this newly create object you want to have some reference to it (optional, but useful). So 'a' is a variable of type A (you can choose to have super type). Now you refer newly created object by 'a', so the name reference variable. there are many more aspects of it like declaring type of variable, declaring variable final, static, concept of runtime
polymorphism etc. I felt, you want the basic concept to start up. You need to further study on your own. There is lot of material on internet regarding your queries.