Forums Register Login
Please help to understand whats the wrong with my guess
Please try to understand why this program produce 100 200 as output. I was expecting out put as 100 200 30 40
(1 like)

I suppose you are expecting that the constructor of MyClass class got called. But actually you are not defining a constructor in MyClass. A constructor doesn't have a return type in its definition.
(1 like)
Hi ,

Rayan as Wayan said . A constructor should only contain the access modifier and not the return type .

Please always indent your code correctly. You are making it hard for yourself because unindented code is difficult to read.

This thread has been viewed 547 times.

All times above are in ranch (not your local) time.
The current ranch time is
Dec 12, 2018 02:18:57.