C Sharp vs. Java

  • comments 0
  • views8,897

Difference between C Sharp and Java

C Sharp and Java both are class based object oriented programming languages. C Sharp was developed by Microsoft whereas Java is product by Sun. Despite some differences, both languages are more or less the same. These are explicitly, strongly and statically typed languages. Both languages use the technique of garbage collection for memory management. Both use the feature of run-time compilation. These languages somewhat differ in reference types, object orientation, fields and initialization, methods and properties and various other fields. Knowledge about these differences can help a programmer to choose one of these languages as per the requirement of the program or software to be developed.

C Sharp
Java

Object Orientation

While both languages use some common object oriented structures such as classes, interfaces and abstract classes, we can still point out some differences in this field. Features like explicit conversions, implicit conversions, indexers, operator overloading, events, properties and partial classes are supported in C Sharp but not in Java. However you cannot create instance level inner classes in C Sharp unlike Java where these are supported. Java also supports overload versioning to some extent.

Expressions and Operators

Most basic operators such as logical, bitwise, arithmetic, conditional, relational etc. are supported by both of these languages. The concept of overflow control is something that can be achieved while working in C Sharp. Ad hoc classes and verbatim strings are also available in C Sharp. It lacks behind in local classes and strict floating point evaluation provided in Java. One more difference that can be pointed out is that Java supports implicit unboxing whereas in case of C Sharp this can be achieved explicitly.

Data Types

C# (C Sharp) supports unsigned integers in contrast to Java. Unlike Java, C# supports various other data types such as high precision floating point number, complex numbers, value types, lifted types, tuples and pointers. On the other hand while working in Java one can use arbitrary size decimals which are not supported in case of C Sharp.

Exceptions

While both languages support the try-catch-finally constructs for exception handling it is important to know that C Sharp doesn't entertain checked exception in contrast to Java. Checked exceptions in Java are those that must be taken care of by the user, either by using throws or try-catch.

Summary

Java

  • Class based object oriented programming language.
  • Sun developed Java.
  • Java supports instance level inner classes.
  • Supports overload versioning to some extent.
  • Local classes and strict floating point evaluation are provided.
  • Can use arbitrary size decimals while working in Java.
  • Supports implicit unboxing.

C Sharp

  • C Sharp was developed by Microsoft.
  • Explicit conversions, implicit conversions, indexers, operator overloading, events, properties and partial classes are supported in C Sharp.
  • Overflow control can be achieved.
  • Ad-hoc classes and verbatim strings are also available.
  • Supports explicit unboxing.
  • Supports various data types such as: high precision floating point number, complex numbers, Value types, Lifted types, tuples and pointers.
  • No “checked” exceptions in C Sharp

 
 

comments Comments

Post a Comment
  • Name*
  • Email*