In below program we have assigned float f=10; that should give us compiler error . but this program compiles fine and gives output 10. what am I missing . please let me know.
SCJP1.5(81%), SCDJWS(94%), next mission SCEA (but need to wait or that)
In below program we have assigned float f=10; that should give us compiler error . but this program compiles fine and gives output 10. what am I missing . please let me know.
You forgot about the implicit casts. An int will implicitedly cast to a float. Hence, it is possible to (look like) assign an int literal to a float (but it is really a cast).