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 Partial class and its use?

1 Answers  


73. How can you set the status and title for a modal dialog box? a) In the attributes of the corresponding screen. b) Before the corresp. call screen statement. c) In a PBO module of the corresponding screen. d) In the PAI module of the corresponding screen.

1 Answers  


what do u mean by html

5 Answers   Infosys,


I need source code for Enrollment System using Visual Basic 6.0/2008 database MS Access 2007 for my school thesis project...please help me..kindly send in my email jpinedamcp@gmail.com

0 Answers  


what is dynamic polymorphism?

2 Answers   Satyam,






Is strus threadsafe or not?

1 Answers  


How should a programmer decide whether to use a macro or a subroutine to accomplish a given logical function

1 Answers   R V College of Engineering, University of Jordan,


What sysoption determines where the macro facility searches a specific catalog for complied macro?

0 Answers   GE,


needs examples for black box testing and white box testing

1 Answers   CTS, IBM, Wipro,


Definition of Singleton Class? what is the Purpose of it? what is the advantage?

0 Answers   Cognizant,


what is the basic and unique feature of dotnet

0 Answers   HCL,


Need provab technical test questions

0 Answers  


Categories