Type casting gives us the ability to change the data type


Q - Type casting gives us the ability to change the data type of variables quite easily. What are some of the uses for this capability and why would we ever want to use this? Please list examples of usage.

A - One use for type casting is converting a floating point type to an integral type in order to truncate the decimal part of the variable. Another use of casting is in taking advantage of polymorphism. Without going into much detail, using class inheritance you can declare variables of a super class type that reference instances of subclass type. Casting can then be used on the superclass type to call methods of the subclass type, as long as it is the correct instance.

Criteria - Write one or two paragraphs. Provide valuable and thoughtful feedback for the above answer with constructive criticism and critiques. Present original thoughts and ideas in postings, (avoid simple agreement or disagreement with, or restatement of other's postings) You may want to provide additional information from your outside readings or other outside resources. I encourage you to share links to other excellent resources during this course.

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Type casting gives us the ability to change the data type
Reference No:- TGS0125136

Expected delivery within 24 Hours