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. Great tutorial. Working absolutely fine. I needed
View Tutorial          By: Ashwin at 2013-02-28 21:45:29

2. thanks i learnt how to use isset in php
View Tutorial          By: free web directory at 2010-09-15 19:42:28

3. Thanks for the syntax, this has really helped me u
View Tutorial          By: Ketobbey at 2010-04-30 19:01:29

4. After a great struggle I am able to successfully c
View Tutorial          By: raghu at 2012-01-04 15:10:07

5. Dear sir i am complete my B.Tech in this year but
View Tutorial          By: Sarvesh at 2012-04-17 15:16:46

6. I am using my NOKIA 2700 via blutooth connection.
View Tutorial          By: Rahi at 2010-05-11 04:39:33

7. Copy the javax.comm.properties into your $JAVA_HOM
View Tutorial          By: sophie at 2009-03-11 08:23:25

8. sir, i am completed MCA 2011 and i want to learn P
View Tutorial          By: vipin kumar at 2011-09-13 13:00:05

9. a bit extra information on robust
View Tutorial          By: mahesh at 2010-02-02 12:05:37

10. i found this very pleasing for both my brain and m
View Tutorial          By: Matthew Redisons at 2012-10-03 14:36:32