void main() X=10 class Test { Y=20 { int x,y,z: Z=X+Y public static void main(String args[]) x=10; print(z) { y=20; int x,y,z; z=x+y; x=10; printf(“%d”,z); y=20; } z=x+y; System.out.println(z); } } Datatype Array
Features of Java: 3
i) Easy to understand and write – easy to use,syntax matching with
traditional languages(C,C++) ii) Secure – presence of JVM every program is written for JVM only not for any hardware or OS. iii) Object Oriented - use the concept of class and objects that is matching with real life concept. iv) Platform Independent -
v) Architectural neutral - architecture may be 32 bit processor ,16bit
processor but particularly for java it doesn’t matter.The only thing that matters is JVM’s size. vi) Robust - exception handling Ex:int x; int y; input x,y; z=x/y; vii) Distributive – java can travel on network and run or execute on different platforms.So java is best language for distributive computing.
For the C program to run on all OS we have to copy test.c file to
the other OS. The .exe file will not work on any other OS.