Вы находитесь на странице: 1из 3

10/31/2017 DIFFERENCE BETWEEN C,C++ AND JAVA

14th September DIFFERENCE BETWEEN C,C++ AND JAVA

DIFFERENCES BETWEEN C,C++ AND JAVA IN A NUTSHELL

S.NO C C++ JAVA


1. Structured programming language Object-oriented programming Object-oriented
language programming language
2. Compiled Compiled Compiled and interpreted
3. 32 keywords 60 keywords 50 keywords
Eg:- case, char Eg:- class, protected Eg:- interface, extends
4. Rules for naming identifier Rules for naming identifier Rules for naming identifier
1. Should begin with alphabet 1. Should begin with alphabet 1. Can begin with alphabet,
2. Can have numbers,underscore 2. Can have numbers,underscore underscore or dollar symbol.
3. Keywords cannot used as identifiers
3. Keywords cannot used as But cannot begin with a
identifiers number
2. Keywords cannot used as
identifiers

5. Comments:- /*….*/ (multi line Comments:- /*….*/ (multi line Comments:- /*….*/ (multi
comment), //(single line comment) comment), //(single line line comment), //(single line
comment) comment), /** ….
*/(documentation comment)
6. Data types :- Data types :- Data types:-
int,char,float,double,void int,char,float,double,void byte,short,int,long,
float,double,
char,boolean

7. Bitwise shift operators are : >> Bitwise shift operators are : >> Bitwise shift operators are :
(right shift),<<(left shift) (right shift),<<(left shift) >>(right shift),<<(left
shift),>>>(triple right shift
operator)
8. Char is 8 bits wide Char is 8 bits wide Java uses Unicode to
represent characters. It is 16
bits wide.
9. Preprocessor directives allowed Preprocessor directives allowed No preprocessor directives
Eg:- #include,#define Eg:- #include,#define
10. Variables need not be initialized Variables need not be initialized Variables must be initialized
before using it before using it before using it
11. Array should be declared Array should be declared Arrays are declared without

http://ugcnetsolved-computerscience.blogspot.in/2017/09/difference-between-cc-and-java.html 1/3
10/31/2017 DIFFERENCE BETWEEN C,C++ AND JAVA

mentioning its size mentioning its size mentioning its size.


Eg:- int num[10]; Eg:- int num[10]; int num[];
num=new int[10] (or)
int num[]=new int[10];
12. Explicit string data type not Explicit string data type not String data type available in
available available java. It is a class
13. Supports pointers Supports pointers Does not support pointers
14. Structures and unions available Structures and unions available Structures and unions not
available
15. - Supports operator overloading Does not support operator
overloading
16. - Programs can be written in c++ All the code in java program
without using a class needs to be written in one or
more classes
17. Global variables and functions are Global variables and functions are No global variables or
allowed allowed functions
18. - Allows default arguments in Not allowed in java
functions
19. - Supports multiple inheritance Multiple inheritance not
supported
20. - Supports constructors and Supports constructors, no
destructors destructors
21. Supports typedef Supports typedef Does not support typedef
22. Unsigned integers can be declared Unsigned integers can be declared No unsigned integers
23. Allows goto Allows goto Does not allow goto
24. - delete operator available No delete operator
25. - Objects may be passed by value or Objects are passed by
by reference reference only in Java

Posted 14th September by Vani Chakraborty

0 Add a comment

http://ugcnetsolved-computerscience.blogspot.in/2017/09/difference-between-cc-and-java.html 2/3
10/31/2017 DIFFERENCE BETWEEN C,C++ AND JAVA

Enter your comment...

Comment as: Nandish SK (G Sign out

Publish Preview Notify me

http://ugcnetsolved-computerscience.blogspot.in/2017/09/difference-between-cc-and-java.html 3/3