Java – Comparing C C++ and Java


Comparing C C++ and Java

These are the famous programming languages which differs from each other, let us see

1. Paradigm

C programming language is a Procedural Programming language where as C++ and JAVA is Object Oriented programming language

What is a Procedural Programming Language ?

Procedural Programming language is also called as Imperative programming language which works in linear approach for the solution.

This works step by step linear top to down approach, which executes routine/sub-routine computational steps in linear way.

C++ and Java is Object Oriented programming language

What is Object Oriented Programming language ?

Object oriented programming language all computational steps are executed by creating class and objects and integrating between objects.

These Objects are connected with real world environment.

Note : C++ will support both Paradigm

2. Platform Dependency 

C and C++ are platform dependent programs

What is platform dependent ?


Programs which depends on Computer Hardware components and Software Components are called as platform dependent.

The execution of C and C++ programs depends on platform, if we take the compiled code and if we try to execute in other Computer hardware and Operating system, and if we try to execute the same program it will not run.

We have to install the compiler in that particular environment and then only the program runs.

Java is Platform Independent programming language 

What is platform independent ?

The source code of particular program which runs in all Hardware/Software components is platform independent

Java have JVM and JRE which compiles the program first as byte-codes and then executes as machine language (0s and 1s) it all platforms irrespective of Hardware/Software components in the computer.

We can copy the byte-code .class file to other platform and execute the same code easily and which works fine.

3. Memory Management

What is computer memory ?

Computer memory is defined as the computer physical hardware device which is capable of processing the instructions and storing the data.

Its is the storage place where the instructions and data is stored.

What are the types of memory ?

Computer memory is of two basic types

1. RAM (Random access memory)
2. ROM (Read-Only memory)

What is Random access memory ?

1. Its the read/write memory also termed as main memory / primary memory.

2. All the external executable computer application programs are stored in this memory.

3. Its termed as volatile memory, because all the data will be lost when the power is turned off.

RAM is further divided in to two types, will be explained in further chapters.

  • Static Random Access Memory (SRAM)
  • Dynamic Random Access Memory (DRAM) 

What is Read-Only memory ?

1. It stores the important crucial informations for operating the whole system, such as booting, running diagnosis and running other system programs.

2. Its a non-volatile memory, when the power is turned off the data will not be lost.

3. Its the permanent memory stored in the computer hard disc.

ROM is further divided in to three types, will be explained in further chapters.

  • PROM (Programmable read-only memory)
  • EPROM (Erasable Programmable read-only memory)
  • EEPROM (Electrically Erasable Programmable read-only memory)

What is Memory management ?

Its a process which controls the memory usage of a computer (CPU/RAM/ROM etc.. )

in C and C++ uses lot of procedures where the memory is allocated in heap, for larger programs the developer must have to free the space and for a long running programs uses can lead to use more memory.

Java memory management is done by Garbage collection process which automatically frees the memory used by the objects which is no longer used, So even for a long programs memory management is effectively done.

4. Multiple Inheritance

Inheritance meaning, something is inherited from some other thing.

but actual inheritance definition is “unique qualities received by the kids from their parents”.

What is inheritance in java ?

Its is the process of creating the new classes which inherits the methods, properties from the parent class.

These new classes are called as sub-class / child-class / derived class.

Other in-depth concepts about inheritance will be explained in further tutorials.

What is Multiple Inheritance ?

Multiple inheritance is like inheriting some features from one or multiple parent classed, its the feature of some object oriented languages that allows you to derive a class from multiple parent classes. 

C++ supports Multiple Inheritance but Java supports Multiple Interface.

What is Interface ?

Interface meaning, Its an intermediate thing across which two independent systems communicate with each other.

What is interface in java ?

Interface is the unique mechanism followed to achieve Abstraction.

Interface can be a class which contains static methods and abstract class.

Other in-depth concepts about interface will be explained in further tutorials.

What is Multiple interface?

Multiple interface is like inheriting some features like methods/objects which has no implementing procedure in it, but inherited from other class which contains implementing procedures.

5. Operator Overloading 

What is an operators in java ?

Its defined as the special symbols which performs specific operations with many operands finally produces the result as output.

There are various types of operators in java, which will be explained in detail in further tutorials.

What is operator overloading ?

Operator overloading enables a class to define special behaviour for built-in operators when they are applied to objects of that class.

We can change the operational procedure of the build-in operators

C++ supports Operator overloading


C and Java does not support Operator overloading.

6. Pointers

What is pointers in c ?

Pointer is usually referred as a variable whose value is the address of another variable, by the way this is direct access to the memory location.

C and C++ supports Pointers where as Java does not support Pointers.

7. Portability And Performance

C and C++ is procedural program which runs efficiently but lacks in memory management as there is not automatic memory cleaning process involved in it.

So for long running programs faces memory issues and memory leaks and that slows the performance of the program.

Java is Object oriented programming language which is also platform independent with Garbage collector inside, cleans the unused memory automatically. 

So for a long running programs the performance is always higher compared to C and C++ programs

8. Application Programs

C and C++ supports linear programming approach, only system application programs can be created.

In Java we can create Web Applications supports Internet programming.

9. Multithreading

What is multithreading in java ?

More than one action can be done at the same time within a program.C and C++ does not support Multithreading.

Java supports Multithreading.


10. Database connectivity 

What is a database ?

Database is an organised collection of data stored and accessed by computer application programs.

What is DBMS ?

Database Management System ( DBMS ) is the software program which manages the databases, it can also handle various process like updating, retrieving and managing database.

In Java,

We can connect the Databases for performing various operations.C and C++ don’t support Database connectivity.

Java supports Database connectivity by establishing JDBC connection.

Comparison table :

C C++ Java
Features Procedural Program

Supports both



Object Oriented Program



Platform Dependency



Platform dependent .



Platform Dependent



Platform Dependent

Memory Management

Not Efficient



Not Efficient



Efficient



Multiple Inheritance

SupportsSupportsDon’t Support


Multiple interface

Don’t Support Don’t Support Supports
Operator Overloading
Supports
Supports

Do Not Support



Pointers

Supports Supports Do Not Support


Portability And Performance
.

Low

Low

High
Application

System Applications



System Applications



Web Applications


Multithreading


Do Not support


Do Not support

Supports
Database connectivity

Do Not support



Do Not support

Supports