Bloomberg LP Interview Question
Financial Software DevelopersThere are various differences between Java and C++. I have attempted to list a few below:
1. There is no support for typedefs, defines, or a preprocessor in Java. Without a preprocesor, there is no provision for including header files in Java. Since there is no concept of preprocessor, there is no concept of #define macros or manifest constants. however, we can declare constants in Java using the 'final' keyword.
2. Java supports classes, but unlike C++, doesn't support the concept of structures or unions.
3. There are no stand-alone functions in Java, unlike C++. Everything is a member function of the class, called 'methods' in Java.
4. There is no concept of global functions or global data in Java; unlike C++.
5. All classes in Java ultimately inherit from the Object class. But in C++, one can have inheritance trees that are completely unrelated to each other.
6. There is no concept of interfaces in C++.
7. Java doesn't support operator overloading or multiple inheritance, unlike C++.
8. In C++, access modifiers can be specified while inheriting from a class. This is not possible in Java.
9. There is no support for automatic type conversions in Java.
10. Doesn't support the concept of pointers.
11. In Java, memory is reclaimed automatically, when all references to it become NULL. In C++, memory has to explicitly be freed.
12. There is a special String type in Java, unlike C++.
13. Unless all variables are specifically initialized in C++, they contain garbage value. Not so in Java.
14. Java doesn't have the 'virtual' keyword because all the non-static methods always use dynamic binding, so it is not required here as in C++.
15. Memory leaks are prevented in Java because of automatic garbage collection.
lot of differences between java n c++ :)....primary being use of pointers.
- Anonymous September 17, 2008in java everything is virtual....so it doesnt have a specific keyword as virtual.
platform independence is the one tht java provides...byte code...code given to the jvm which then creates an executable n runs it...