Difference between C, C++ and Java



C language

1- The program execution starts from main method and main method is called by Operating system.

2- In the c-language the predefined support is maintained in the form of header files

Ex:- stdio.h,conio.h

3- the header files contains predefined functions.

Ex:- printf,scanf…..

4- to make available predefined support into our program we have to use #include statement.

Ex:- #include<stdio.h>

5- memory allocation: malloc
Memory deallocation: free

6- size of the data types are varied from operating system to the operating system.

16-bit int -2bytes char- 1byte
32-bit int -4bytes char – 2 bytes

7- to print some statements into the console we have to use “printf” function.

8- C is dynamic language the memory is allocated at compilation time.

C++ language

1- The program execution starts from main method called by operating system.

2- In the cpp language the predefined is maintained in the form of header files.

Ex:- iostream.h

3- The header files contains predefined functions.

Ex:- cout,cin….

4- To make available predefined support into our program we have to use

#include statement.
Ex:- #include<iostream>

5-Allocation :constructor

6- Deallocation:destructors

7- Irrespective of any os

Int -4
Char-2

8- To print the statements we have to use “cout”
Cpp is static language the memory is allocated at compilation time.

Java language

1- The program execution starts from main method called by JVM(java virtual machile).

2- In the java language the predefined is maintained in the form of packages.

 Ex:- java.lang java.io java.net java.awt

3- The packages contains predefined classes.

Ex:- String,System

4- To make available predefined support into our program we have to use
import statement.

Ex:- import java.lang.*;

5- Allocation :constructor

6- Deallocation:Garbage collector(part of the jvm)8-Irrespective of any os

Int -4
Char-2

7- To print the statements we have to use “System.out.println”

8- Java is dynamic language the memory is allocated at runtime time



No comments:

Post a Comment