0

Hello,
I am in Object Oriented Design for C++ at the moment...
The test we are having has a question on it and the professor wants us to find and know the answer before we come in for the test.

The question is this:
The following code out puts what for each language:

x=3;
y=x;
(1)   print x, y
x=5;
(2)   print x, y

Python: (1) 3, 3 (2) 3, 3

Java: ?

C++: (1) 3, 3 (2) 3, 3

I am guessing... that Java would be: (1)3, 3 (2)3, 5

Edited by Blitze: n/a

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Blitze
0

Java doesn't have a function called "print" however I assume that this is pseudo code.

Java is also very similar to c++, so you should have no problem figuring out what is going on.

But the output would be
(1) 3, 3
(2) 5, 3 <- remember that x is being reset to 5

0

I see, and i am sorry to all I ended up making a typo the C++ answer is wrong..

C++: 1) 3, 3 2)5, 3


Thus all three languages would do the same in this case...

Edited by Blitze: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.