Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is type casting. Explain it with reference to classes.

Answer Posted / shubha

Type Casting is conversion of one type data to another type.

Ex:
public class Base{
//Your code goes here
}

public class Derived extends Base
{
//Inherit method or create your own code here
}

public class MainClass {
public static void main(String args[]){

Base b = new Derived(); //reference variable of Base class points object of Derived class
//Derived d = b; compile time error, requires casting
Derived d = (Derived) b; // type casting Base to Derived
//Here you call your base class methods as derived class methods
}
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between do and while loop?

853


what is scope of a protected internal member variable of a c# class

980


What is a partial class. Give an example?

931


What is data annotation in c#?

887


Is vs as c#?

862


Is 0 an unsigned integer?

855


How do I know if executenonquery is successful c#?

802


How does array sort work?

858


What is a static field?

867


What is mvc pattern in c#?

888


Where is c# compiler located?

890


What is namespace c#?

884


How long will it take to learn c sharp?

897


What is the meaning of extention?

934


If a.equals(b) is true then a.gethashcode & b.gethashcode must always return same hash code.

971