473,406 Members | 2,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

explict consructor calling

sanjay123456
125 100+
Dear Friends ,

in java the creation of object of class hello is following

hello h = new hello();
here hello() means call explictely constructor calling mechnism

but in c++

we write only helllo h;

and object is created and implictely constructor is callling

my question is this why java is call explictely constructor mechnism is accepted
why we do not write only hello h; and after that implictely constructor is called

what is meaning of explictely constructor mechnism in java ?
why is required ?


sanjay
Feb 7 '07 #1
4 1194
r035198x
13,262 8TB
Dear Friends ,



in java the creation of object of class hello is following



hello h = new hello();

here hello() means call explictely constructor calling mechnism



but in c++



we write only helllo h;



and object is created and implictely constructor is callling



my question is this why java is call explictely constructor mechnism is accepted

why we do not write only hello h; and after that implictely constructor is called



what is meaning of explictely constructor mechnism in java ?

why is required ?





sanjay


Because in Java you create objects only through the new keyword.
Feb 7 '07 #2
dmjpro
2,476 2GB
i think u r from c++ background
if u write hello h() means in c++ ............is a function declaration..
h is a function which returns object type hello.
in java there is no direct access of object only access to object reference that is implicit pointer
in java hello h means a object reference with null value until and unless u use new the jvm does not give it the memory
need any more help plz send me reply..
i am online...
Feb 8 '07 #3
Dear Friends ,

in java the creation of object of class hello is following

hello h = new hello();
here hello() means call explictely constructor calling mechnism

but in c++

we write only helllo h;

and object is created and implictely constructor is callling

my question is this why java is call explictely constructor mechnism is accepted
why we do not write only hello h; and after that implictely constructor is called

what is meaning of explictely constructor mechnism in java ?
why is required ?


sanjay


Hi,

In java if we gave as Hello h means it just create a reference and not an object. Only after using new only the object fo the class is created.

Hello h; - > Reference
Hello h = new Hello() - > Object
Feb 8 '07 #4
dmjpro
2,476 2GB
okay...
in second case the h holds the address of the object
Feb 8 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Muthu | last post by:
I've read calling conventions to be the order(reverse or forward) in which the parameters are being read & understood by compilers. For ex. the following function. int Add(int p1, int p2, int...
4
by: Ganesh Gella | last post by:
Hi All, While going through xalan's XSLT source code, I came across few constructors which are qualified as "explicit". These constructors are empty constructors. I read about the use of...
2
by: Ganesh Gella | last post by:
Hi all, I have seen few places where constructors are declared like this. class A { explicit A(){}; }; I can understand this, class A {
7
by: Klaus Friese | last post by:
Hi, i'm currently working on a plugin for Adobe InDesign and i have some problems with that. I'm not really a c++ guru, maybe somebody here has an idea how to solve this. The plugin is...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
3
by: Mike | last post by:
Timeout Calling Web Service I am calling a .NET 1.1 web service from an aspx page. The web service can take several minutes to complete its tasks before returning a message to the aspx page. ...
6
by: Christopher Lusardi | last post by:
How can I fix this? When I do the below I get the error message: "Cannot insert explict value for identity column in table 'Employees' when IDENTITY_INSERT is set to OFF." To get this message,...
7
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a C# logging assembly with a static constructor and methods that is called from another C# Assembly that is used as a COM interface for a VB6 Application. Ideally I need to build a file...
10
by: sulekhasweety | last post by:
Hi, the following is the definition for calling convention ,which I have seen in a text book, can anyone give a more detailed explanation in terms of ANSI - C "the requirements that a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.