JAVA VS OTHER OOPS LANGUAGES

 

C++ Vs Java
 

C++

Java

1.

Compatible with C source code, except for a few corner cases.

No backward compatibility with any previous language. The syntax is, however, strongly influenced by C/C++.

2.

Write once, compile anywhere (WOCA).

Write once, run anywhere / everywhere (WORA / WORE).

3.

Allows procedural programming, functional programming and object-oriented programming.

Java Strongly encourages an object-oriented programming paradigm unlike C++ programming.

4.

C++ Programming Allows direct calls to native system libraries.

Call through the Java Native Interface and recently Java Native Access

5.

Exposes low-level system facilities.

Runs in a virtual machine.

6.

C++ Only provides object types and type names.

Is reflective, allowing meta programming at runtime.

7.

Supports native unsigned arithmetic.

No native support for unsigned arithmetic.

8.

Operator overloading for most operators.

The meaning of operators is generally immutable, but the + and += operators have been overloaded for Strings.

9.

Full Multiple inheritance, including virtual inheritance.

From classes, only single inheritance is allowed. From Interfaces, Multiple inheritance is allowed.

10.

'const' keyword for defining immutable variables and member functions that do not change the object.

'final' provides a version of const, equivalent to type const pointers for objects and plain const for primitive types only. No const member functions, nor any equivalent to const type pointers.

11.

Supports the goto statement.

Supports labels with loops and statement blocks.

12.

Source code can be written to be platform-independent (can be compiled for Windows, BSD, Linux, Mac OS X, Solaris, etc., without modification) and written to take advantage of platform-specific features. Typically compiled into native machine code

Compiled into byte code for the JVM. Byte code is dependent on the Java platform, but is typically independent of operating system specific features.

 

Ruby Vs java
 

Ruby

Java

1.

You can run the programme directly,there is no need for compilation.

You have to compile your programme and then you can run .

2.

It has the "end" keyword after defining things like classes, instead of having to put braces around blocks of code.

It supports only braces around blocks of code.

3.

It "require" instead of import

It has import.

4.

All member variables are private. From the outside, you access everything via methods.

Its members are by default public.

5.

Parentheses in method calls are usually optional and often omitted.

Parentheses in methods are mandatory.

6.

There's no static type checking.

There's static type checking.

7.

There's no casting. Just call the methods. Your unit tests should tell you before you even run the code if you're going to see an exception.

There's two types of casting.1.Upcasting.
2.Downcasting.

8.

The constructor is always named "initialize" instead of the name of the class.

The constructor's name is same as that of class name.

9.

It has "mixin's" instead of interfaces.

It has interfaces.

10.

YAML tends to be favored over XML.

It supports XML.

11.

Its nil instead of null.

Its null.

12.

== and equals() are handled differently in Ruby. Use == when you want to test equivalence in Ruby (equals() is Java). Use equal?() when you want to know if two objects are the same (== in Java).

== and equals() are same if they are not overriden, or else if they are overriden then are different.