what is object type casting? give some example with related?

Answer Posted / aaratim

Object type casting is converting a object type into another
type. For example

Iterator ite = emplist.iterator();
while(ite.hasNext()){

Employee empObj = (Employee)ite.next();

}

Here ite.next returns instance of type Object, we need to
convert it to type Employee so this is called type casting.

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we declare the static variables and methods in an abstract class?

546


What happens if we override only equals?

582


Why does java not support operator overloading?

660


What is a memory leak in java?

547


Can a final method be overloaded?

510






When is finally block not called?

582


What is the indent key?

592


What is size of int in java?

547


Write a function to print Fibonacci series and Tribonacci series?

760


Define how objects are stored in java?

565


Can you call a method in a method?

531


How many inner classes can a class have?

580


Is alive and join method in java?

540


Which is better ascii or unicode?

572


What is finalize() function in java?

563