Explain upcasting and downcasting in Java.

Explain upcasting and downcasting in Java.

Upcasting: Java permits an object of a sub class can be referred by its super class. It is done automatically.

Downcasting: It is to be performed manually by the developers. Here explicit casting is to be done by the super class.

Shape shape = new Shape() ;
Circle circ;
circ = (Circle) shape;

where shape is a super class object. Now the methods of Shape can be invoked by the reference variable circ.
Can you explain benefits of classpath?
Classpath is the path in which JVM searches for class libraries at the time of compiling the Java Application. By setting the CLASSPATH environment variable....
Explain the reason of Out of Memory exception in Java
The OutOfMemoryException can occur either the JVM may have a limit of memory to access to, or the system may have run out of physical memory....
What will happen when ResultSet is not closed?
In a pooled database connection, it is returned to the pool and could close only after expiring its life time......
Post your comment

You may like