just a quick questions that has been bugging me for a few days:
lets say i have some classes X and Y, and in some other part of the program, I make this declaration:
X xObject = new yObject();
What does that do?
thanks
5 1069
just a quick questions that has been bugging me for a few days:
lets say i have some classes X and Y, and in some other part of the program, I make this declaration:
X xObject = new yObject();
What does that do?
thanks
that does not work
but you can cast to do that
ex: X xObject =(X)( new yObject());
that does not work
but you can cast to do that
ex: X xObject =(X)( new yObject());
of course if casting is allowed which will depend on the types of x and y
just a quick questions that has been bugging me for a few days:
lets say i have some classes X and Y, and in some other part of the program, I make this declaration:
X xObject = new yObject();
What does that do?
thanks
You can do - List c = new ArrayList();
.
Think about it and come up with the instances where it is allowed to do so. Don't forget to test for interfaces as well ...
ok, lets say its type casted. i dont understand what the xObject becomes if the yObject is stored into it.
thanks
ok, lets say its type casted. i dont understand what the xObject becomes if the yObject is stored into it.
thanks
How about you think about this in terms reference types and what they are pointing to?
e.g
The reference x of type X is pointing to an object of type Y.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Daniel |
last post by:
Hello =)
I have an object which contains a method that should execute every x ms. I
can use setInterval inside the object construct like this -
self.setInterval('ObjectName.methodName()',...
|
by: Kevin Prichard |
last post by:
Hi all,
I've recently been following the object-oriented techiques discussed
here and have been testing them for use in a web application. There is
problem that I'd like to discuss with you...
|
by: Water Cooler v2 |
last post by:
I am new to PHP, just one day new. But I am otherwise a seasoned
programmer on many other languages like C, VB 6, C#, VB.NET, Win32
platform and have some tiny bit experience in MFC, C++, Python.
...
|
by: zouyongbin |
last post by:
Stanley B Lippman in his "C++ Primer" that a definition like this
should not appear in a header file:
int ix;
The inclusion of any of these definitions in two or more files of the
same...
|
by: alex |
last post by:
I am so confused with these three concept,who can explained it?thanks
so much?
e.g.
var f= new Function("x", "y", "return x * y");
function f(x,y){
return x*y
}
var f=function(x,y){
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |