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:

(1)   print x, y
(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

Recommended Answers

All 2 Replies

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

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...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.