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

Can main method be final?

859


What is the difference between ienumerable and enumerator?

855


Why is c# a good programming language?

917


So what makes your code really object-oriented #?

901


What method is used to sort the elements of the array in descending order?

897


what is c# command?

931


What is default parameter in c#?

904


What is asp net in c#?

904


Why singleton is sealed?

800


How to transpose multi-dimensional array?

1005


What is a thread? What is multithreading?

890


Is exe is machine dependent?

883


What is the difference between a function and a method?

911


What does dbml mean?

824


What does using system mean in c#?

961