what are upcasting and downcasting?

Answer Posted / malligontla

A super class reference can be converted into a subclass
reference but this subclass reference is not useful to call
the methods of any of the classes. This convention is known
as Downcasting.

We can convert the subclass reference to a superclass
reference without using the cast operation, because compiler
will internally take care of the casting. This is known as
Upcasting.

Is This Answer Correct ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between arraylist and hashset in java?

514


Is java ee a framework?

516


Which java ide is used the most?

505


List the different types of classloaders in java.

501


What is binary tree in java?

528






What differences exist between iterator and listiterator?

567


What is java command?

567


Where is core java used?

576


What is jar?

629


Can a set contain duplicates?

515


What is variable length arguments in java?

512


What is lifetime variable?

521


What is arraylist e?

557


What is javac in java?

558


What are synchronized methods and synchronized statements in java programming?

568