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

How do you control extraneous variables?

684


Why are the objects immutable in java?

750


What does sprintf mean?

727


What are the types of methods in java?

789


what is the major difference between linkedlist and arraylist in java?

788


What is protected access modifier?

796


Explain different ways of creating a thread?

756


What is anagram in java?

716


What is function declaration?

725


What is the difference between preemptive scheduling and time slicing in java programming?

789


Why is the main method declared static?

856


How do I get 64 bit java?

718


Why singleton is not thread safe?

776


Explain the difference between abstract classes and interfaces in java?

842


What is the final field modifier?

751