Upcasting and downcasting in Java

          

Explain upcasting and downcasting in Java.

<<Previous   Next>>

Java - Explain upcasting and downcasting in Java. - March 16, 2010 at 15:05 PM by Vidya Sagar 

Explain upcasting and downcasting in Java.

Upcasting: Java permits an object of a sub class can be referred by its super class. It is done automatically.

Downcasting: It is to be performed manually by the developers. Here explicit casting is to be done by the super class. For example:

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

where shape is a super class object. Now the methods of Shape can be invoked by the reference variable circ. 

<<Previous   Next>>
What is the purpose of the enableEvents() method?

An event-listener interface allows describing the methods which must be implemented by one of the event handler for a specific event..................

What is the difference between preemptive scheduling and time slicing?

Preemptive scheduling enables the highest priority task execution until waiting or dead states entered. It also executes, until a higher priority task enters.................

String objects are immutable in java. Explain how to create a string that can be changed.

A string object that is created using “String” class is immutable. The characters of the object can not be changed / modified. There are some methods, such as split(), substring(), beginsWith() etc................... .

Write your comment - Share Knowledge and Experience


 

 
Interview questions
 
Home | Want a Job? Submit Key Skills | Employer login | My key skills | About us | Sitemap | Contact us