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

Need provab technical test questions

0 Answers  


Q2. A memory location has physical address D5687h. Compute: a. The offset address if the segment number is D445h. b. The segment number if the offset address is B577h.

0 Answers  


In Java what is the difference between following two statements ? int a[],b; int []a,b;

1 Answers  


What is Console Application? & The purpose Of Console Application? with description.

1 Answers  


how to generate dsnless connectivity in j2ee

0 Answers  






write a sql qwery which include joining of two tables 4 marks mainframe

0 Answers  


7.x=10; y=20; x<<2=? x<<1=? y>>2=?

1 Answers  


what is the similarity between networking devices?

0 Answers   Cygnus, Infosys,


What is abstract Method i want the exact definition and is there any possibility to declare class as abstract without any abstract methods in that class?If it is possible then tell me why and how?

0 Answers  


It is possible to take number of controls added to form at run-time.ex-when user enter 6, 6 text boxes get added to form,next time number of controls get change as per user number enter. What is code for that?

0 Answers   Honeywell,


To sorting array of 10 elements which sorting is best a)selection b)bubble c)tree sort

2 Answers   HP, Hughes,


design a counter with the following repeated binary sequence: 0, 1, 2, 3, 4, 5, 6, 7, 8 using JK Flip Flop.

3 Answers   College School Exams Tests, IBD, IBM, Ignou, IIIT, Nortech, TCS, UOS,


Categories