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

WAP to print all prime nos between 1 to 100 without using user input...pls reply within few hours...

1 Answers  


There are 2 tables: EMP : EmpId, Ename, Sal, DeptId DEPT : DeptId, Dname Write a query to find out emp names and their department names. if any emp has null in Deptid the it shows ?No Department?. Write a query to find out those department names which has no employee. Write a query to find out those employees whose salary is greater than their department?s average salary.

1 Answers   Oracle,


What is the difference between: x=a+b+c+d; and x=SUM(a,b,c,d);?sas

5 Answers  


1. Write a program to create a sentence at runtime and count number of vowels in it ? 2. Write a program to get a string and to convert the 1st letter of it to uppercase ?

0 Answers   HTC,


What is the difference between an EXE and a DLL?

3 Answers   ABC, Hykin Solutions, Infoedge, Infosys, Polaris,






what is the extension of SPDS Dynamic cluster tables?

0 Answers   IBM,


where is available in this mantis toturials?

0 Answers  


why we need to take u?

0 Answers  


What's the difference b/w Table & Templete in Smartform?

0 Answers   Accenture,


How will you prove that java swing is multithreaded?

0 Answers  


Given a arbitrary pointer to an element in a singly linked list?what is the time complexity for its deletion .

1 Answers   Hughes,


In loading programs into memory, what is the difference between load-time dynamic linking and run-time dynamic linking?

0 Answers  


Categories