Computer Science, asked by RuhiY, 11 months ago

state need of typecasting in Java

Answers

Answered by amanpeekay0
14

Hey Mate!


Here's the answer :-

Typecasting, is a method of changing an entity from one data type to another. It is used to ensure variables are correctly processed by a function.

Answered by aqibkincsem
9

Type casting is used to convert an object or variable of one type into another. Java is an Object oriented programming language.

It’s easy that Super class reference variable is pointing to SubClass object but there is no way for Java compiler to know that a Superclass variable is pointing to SubClass object.

In order to do that, we first need to cast the Object back into its original type. So we nned typecasting.

Similar questions