Comment on Tutorial - Type Casting in Java By Saravanan



Comment Added by : siddhant

Comment Added at : 2014-10-11 13:19:25

Comment on Tutorial : Type Casting in Java By Saravanan
Design program with given algorithm---

step1:Declare a variable x of type integer and assign it to the value 10
Step 2: Declare a variable y of type double and assign it the value of x.
Step 3: Print the value of y it will show no error itâs called implicit casting.
Step 4: Now, Set the value of y to 13.5
Step 5: Assign value of y to the x. (It raises compilation error because implicit casting doesnât work as explained.)
Step 6: Use explicit casting (narrowing conversion) to assign y to x.
Step 7: print value of x (it gives you round off value y).
Step 8: Define a class named vehicle as a parent class, define a subclass of vehicle as car.
Step 9: create an object x of class vehicle.
Step 10: create an object y of class car.
Step 11: assign y to x (Its upcasting so no compilation error and no explicit casting is required)
Step 12: assign x to y (Its downcasting so it will give u compilation error. So use explicit casting)


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. hi..... i m newly in java ,i want to learn about t
View Tutorial          By: ashwini at 2012-08-09 08:01:34

2. can any one plz tell me which java comm api do we
View Tutorial          By: GAURAV MODI at 2010-01-29 02:12:13

3. at
OK
at+cmff=1
OK
at+

View Tutorial          By: shrinivas at 2009-03-07 23:16:51

4. nice code. code is running perfectly. but my probl
View Tutorial          By: Avinash at 2013-01-28 07:30:19

5. I need full code for how to connnect pc to mobile
View Tutorial          By: Vijay at 2009-08-23 23:38:05

6. it is very nice example of overloading when i read
View Tutorial          By: narendra saini at 2012-04-20 04:03:56

7. Thanks for the tutorial. I didn't get a lot of tra
View Tutorial          By: jordan at 2012-05-16 13:03:45

8. it worked n this case but could not find some more
View Tutorial          By: abhilash koleti at 2012-09-14 16:21:58

9. great resource
View Tutorial          By: Anonymous at 2011-04-14 03:14:43

10. it's cool
but on other way it is indeed har

View Tutorial          By: johncarlo at 2009-02-05 04:44:13