Friday, March 12, 2010

Different Between C# and JAVA



Like C#, Java was also derived from C++ and therefore they have similar toots. Moreover, C# was developed by Microsoft as an alternative to Java from web programming. C# has borrowed many good features from Java, which has already become a popular language. However, there exist a number of difference between C# and Java.

1.
C# has more primitive data types.

2.
although C# uses .NET runtime that is similar to Java runtime, the C# compiler
produces an executable code.

3.
Unlike Java, all C# data types are objects.

4.
Array are declared differently C#.

5.
Although C# classes are quite similar to java classes, there are a few
important difference relating to constants, base classes and constructors,
static constructors, versioning, accessibility of members etc.

6.
Java uses static final to declare a class constant while C# uses use const.

7.
The convention for java is to put one public class in each file and in fact,
some compilers require this. C# allows any source file arrangement.

8.
C# supports the struct type and java does not.

9.
Java does not providing operator overloading.

10.
In Java, class members are virtual by default and method having the same name in
a derived class overrides the base class members. In C#, the base member
is required to have the virtual keyword and the derived member is required to use
the override keyword.

11.
C# providing better versioning support than Java.

12.
C# provides static constructors for initialization.

13.
C# provide built-in delegates and events. Java uses interfaces and interfaces
and inner classes to achieve a similar result.

14.
In Java, parameters are always passed by value.
C# allows parameters to be passed by reference by using the ref keyword.
15.
C# adds internal, a new accessibility modifier. Members with
internal accessibility can be accessed from other classes within the
same project, but not from outside the project.

16.
C# include native support for properties, Java does not.

17.
Java does not have directly support enumerations.

18.
Java does not directly support enumerations.

19.
Both Java and C# support interfaces. But, C# does not allow type
definitions in interfaces, while Java interfaces can have const type data.

20.
In java, the switch statement can have only integer expression, while C#
support either an integer or string expressions.

21.
C# does not allow free fall_throuhg from case to case.

22.
C# provides a fourth type of integration statements, foreach for quick and
easy iterations over collections and array type data.

23.
Catch blocks should be ordered correctly in c#.

24.
C# checks overflows using checked statements.

25.
C# uses is operator instead of instanceof operator in java.

26.
C# allows a variable number of parameters using the params keyword.

27.
There is no labeled break statement in c#. the goto is used to achieve this.

No comments:

Post a Comment