Access specifiers actually work with respect to classes.
So if we assign something private, it means that only within that class that member can be accessed and outside it, not.
The second part was not my question.
Sorry for not being very clear about that. I was just trying to make it clear what I know.
Thank You for your help again. I understood a bit what you said.
But I have read in a book that an object can be static and an example was given that in case of
System.out.println()
println() is a method of object out which belongs to the class System.
And we can use the method println() without instantiating any object in System because the object out is Static.
Hello
I would like to know about static obects in Java.
Since objects are created by instantiating classes. How can we have an static object in a class??
What I have read is that here run time polymorphism is applied. As it is during the run time that it is decided which method will get overridden and get used.
From another source what I have read is that in normal cases we can use members of the base class through subclass. But in case of dynamic method dispatch we are able to access members of subclass from base class. Is it really the case? I am a bit confused with this explanation.
Can any of you please help me out with dynamic method dispatch. This is not very clear to me.
If someone can please elaborate on this it will be of great help.