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

needs examples for black box testing and white box testing

1 Answers   CTS, IBM, Wipro,


how to study PHP my own? i reffered many sites.. but as being a fresher i couldnt follow those... which site will be the best one?

1 Answers  


What is the difference between DECISION COVERAGE(DC) and MODIFIED CONDITION/DECISION COVERAGE(MCDC)?

1 Answers  


what are all the validation we need to perform in data stage?

1 Answers  


write a program on c(or)c++(or)java language i.e if i have 5 numbers like (10,24,3,9,15) i want to display highest number from these numbers

2 Answers  


what is the difference between SCAN AND CHECK,LOKUP AND XFOOT? where we can use thease opcodes? Can any body tell me real time senariao with example?

1 Answers  


what is the difference between rename and label

1 Answers   Satyam,


What do you understand by modular programming?

1 Answers   Tech Mahindra,


what are the steps for creating prompt table dynamically for the specified field

0 Answers  


Diff.b/w Frames and container?

1 Answers   Tech Mahindra, Wipro,


can any method return type may be constructor , or that method name allow

1 Answers   HCL,


what is the last ant version you worked?how to get it

1 Answers  


Categories