Computer Science, asked by lfstone3, 1 year ago

upcasting and downcasting examples. Some commonly used default string method. (JAVA)

Answers

Answered by akhildestan
1
Down casting 

Animal animal = new Dog();

Dog dog = (Dog) animal;

here animal is a higher variable type and dog is lower. Then we down casting animal as Dog type in second line.

Up casting will be opposite ...

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


 
Similar questions