Why we need new operator in java at the time of object
declaration and why not in c++?



Why we need new operator in java at the time of object declaration and why not in c++?..

Answer / anuja joshi

The major difference between Java and C++ is the behavior of object variables. In C++, object variables hold values, not object references. Note that the new operator is never used when constructing objects in C++. You simply supply the construction parameters after the variable name.

Point p(1, 2); /* construct p */

If you do not supply construction parameters, then the object is constructed with the default constructor.

Time now; /* construct now with Time::Time() */

This is very different from Java. In Java, this command would merely create an uninitialized reference. In C++, it constructs an actual object.

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More Programming Languages AllOther Interview Questions

What is the best action a system can take when deadlock is detected

2 Answers  


What is the language used for Artificial Intelligence?

1 Answers  


Hi can you please help for the following. I have a ASP.Net web page I want to print the whole page how is it possible? I want It in ASP also.Please send me the solutions dipankar.hazari@gmail.com . Thanks in advance.

0 Answers   Philips,


What is the Super Class of Exception in java?

11 Answers   Andesa Services, Benchmark, CitiGroup, CMC, Evergent, KOT Systems, Value Labs, Vijay infoart Solutions,


What is nocopy in plsql?

1 Answers   IBA Health,


Can anyone send me NIC question papers alongwith answers on nidhi1485@yahoo.co.in? Urgently needed.. Thanks in advance

0 Answers  


if there are n nodes in a binary tree, how many null pointers are there?

4 Answers   Hughes,


Which tag is used to break a line

3 Answers  


how to avoid java script validation in client side validation?

2 Answers  


About CLR, reflection and assemblies?

2 Answers   pspl,


Is there any standard procedure to test the application as a whole? Or How can I test complete application right from the requirement gathering?

0 Answers  


What is %Type,%Rowtype?

0 Answers  


Categories