Difference between the C++ and JAVA ?
This article mainly concentrate on the exploration of the power of the JAVA.
We can implement all the features which are present in the JAVA, in C++ also except the two features.
1. Security
2. Platform Independence.
The main difference between the C++ and JAVA is SECURITY and PLATFORM INDEPENDENCE.
1. SECURITY :
SECURITY for any language means accessing its data, but which kind of data ?
here the language security is accessing its PRIVATE data i.e., which is declared as PRIVATE.
In C++:
Both C++ and JAVA are Object Oriented Programming languages, and both of them supports the feature i.e, Data hiding ( data is hided behind the object if you want to access those data you have to its object). This feature of the OOP is also called as security.
But is C++ we can break this feature that means we can access those data without its object.
How ?
example:
class data
{
private:
int a;
public:
void showA()
{
cout<<"a value is:"<<a;
}
};
void main()
{
data d;
int *ptr;
//accessing address of the d
ptr(int)=(int)&d;
//print the value of before the assignment through the pointer.
d.showA(); //probably you may get garbage value
//assign value to 'a' through the pointer
*ptr=2;
//now print the value
d.showA(); //you will get output a value is :2
getch();
}
In JAVA:
Here actually there is no concept of 'pointers' so that you can't make access of the another variable illegally. So that JAVA is more secure.
2. PLATFORM INDEPENDENCE:
PLATFORM independence means the program you have written should be run on all machines.
IN C++:
What a compile does is it will convert the source language into the assembly level language. In the process of the conversion of these high level instructions into assembly level language it will convert according to the configuration of the machine (CPU registers and other other elements) So that if you run your final output in another system with different configuration means other CPU then it won't work because the CPU is different. So Platform dependent.
IN JAVA:
The main Problem with C++ is if the processor is not the same as you developed in then it will not work. So we should have to develop code for common MACHINE (CPU). So in JAVA there is a machine which is software machine which is common wherever you get installed. I mean here we are providing a Virtual Machine to replace the problem of requirement of same MACHINE. This software Machine is called JAVA VIRTUAL MACHINE.
Only by these 2 reasons JAVA is powerful.
This article is to the differentiate C++ and JAVA.
by
K.Partha Saradhi Reddy.
G.V.N.Yaswanth.
R.S.M.S. Vamsi Krishna.
For any queries mail us: programmersband@gmail.com
![]() |
| Difference between C++ and JAVA |
This article mainly concentrate on the exploration of the power of the JAVA.
We can implement all the features which are present in the JAVA, in C++ also except the two features.
1. Security
2. Platform Independence.
The main difference between the C++ and JAVA is SECURITY and PLATFORM INDEPENDENCE.
1. SECURITY :
SECURITY for any language means accessing its data, but which kind of data ?
here the language security is accessing its PRIVATE data i.e., which is declared as PRIVATE.
In C++:
Both C++ and JAVA are Object Oriented Programming languages, and both of them supports the feature i.e, Data hiding ( data is hided behind the object if you want to access those data you have to its object). This feature of the OOP is also called as security.
But is C++ we can break this feature that means we can access those data without its object.
How ?
example:
class data
{
private:
int a;
public:
void showA()
{
cout<<"a value is:"<<a;
}
};
void main()
{
data d;
int *ptr;
//accessing address of the d
ptr(int)=(int)&d;
//print the value of before the assignment through the pointer.
d.showA(); //probably you may get garbage value
//assign value to 'a' through the pointer
*ptr=2;
//now print the value
d.showA(); //you will get output a value is :2
getch();
}
In JAVA:
Here actually there is no concept of 'pointers' so that you can't make access of the another variable illegally. So that JAVA is more secure.
2. PLATFORM INDEPENDENCE:
PLATFORM independence means the program you have written should be run on all machines.
IN C++:
What a compile does is it will convert the source language into the assembly level language. In the process of the conversion of these high level instructions into assembly level language it will convert according to the configuration of the machine (CPU registers and other other elements) So that if you run your final output in another system with different configuration means other CPU then it won't work because the CPU is different. So Platform dependent.
IN JAVA:
The main Problem with C++ is if the processor is not the same as you developed in then it will not work. So we should have to develop code for common MACHINE (CPU). So in JAVA there is a machine which is software machine which is common wherever you get installed. I mean here we are providing a Virtual Machine to replace the problem of requirement of same MACHINE. This software Machine is called JAVA VIRTUAL MACHINE.
Only by these 2 reasons JAVA is powerful.
This article is to the differentiate C++ and JAVA.
K.Partha Saradhi Reddy.
G.V.N.Yaswanth.
R.S.M.S. Vamsi Krishna.
For any queries mail us: programmersband@gmail.com






.jpg)
0 comments:
Post a Comment