C/C++ and Java
a.Java got inspired by C++ during its design time so it shares most of common features that are part of C++. But There is varying degree of difference when it comes to actual implementation of C++ features in Java.
b.Java is object oriented language as C++. All classes in Java inherit from the Object class, but this behaviour differs in C++.
c.Java has inheritence just like C++ does, but it does not support Mulitple inheritence.
d.Like C++ in Java there is constructor but notable difference is no distructor in Java. Automatic Garbage collection frees up the unused memory once the object is out of scope. This can be big boon as most of
C++ bugs relates to memory leaks, or there is no double free/corruption as well.One more difference with Constructor is that there is no "new" keyword while creating the instances of object.
5.In Java all method definitions are contained within the class definition, Unlike C++ where method defination can be found outside the class. The "inline" keyword does not work in Java, methods are made inline by the Justin time compiler(JIT) as required.
6.Java language always uses call by value, while has both call by Value and call by reference using (&) parameter.
7.Java does not have most frowned upon "goto" statements(But internally compiler treats it as keyword so we can't use it for any local or global variables). Instead Java features break,switch continue statements to mimick this behavior. Also I found Java has Label: feature which almost does the same thing as goto except that it cannot be used within the Loop.
As I used C in my career as well,I would like to state few differences with C as well.
1.In Java there is Exception handlers, In C there is none. In C this feature usually accomplished by using complex nested if/else or switch case statements on the return value of the function.
2.Memory is dynamically handled in Java. While in C we use malloc/free, This gives greater control over memory and great feature in Embedded programmes to conserve memory but can be error prone if we are working at distibuted projects with lot pointers floating around without getting freed.
3.In C primitive types has signed/unsigned, while java there is no unsigned/signed builtin types.
4.In C equivalent of class is structure; Here notably there is no control over visibility of members.All are public.
I am sure there are many more differences than listed over here for both C and C++ , I think these are only difference I found relevant taking my first peek at Java.












