Interesting Java question
A friend of mine who's a compsci recently presented to me a past question on Java which I thought was really interesting. I don't do java but I do C++ and since the two are closely related I tried to have a bash at it but failed. Neways, thought u guys might like to give it a shot (only if u're interested) and if u do pls post ur thoughts as I would be very interested to hear them.
Question: Write a Java code that when compiled into a program and executed will display the same output as running cat %source file% |
Code:
import java.io.*; Save it as myReader.java, compile and then run with: java myReader <filename> which prints out the file as does: cat <filename> |
Ok errmm, sorry, I forgot to mention, you can't use File I/O ..sorry, silly me.
|
Ahhhh yes, well that changes things slightly!
|
Man! seems like you have to write your own Java decompiler.
|
Well LMAO at least it doesn't use IO eh? :P
Code:
class Cat |
that's the classic "self reproducing" program, I have seen the code of such a program in an old language. The most common application of this kind of programs is virus that reproduces itself.
|
All times are GMT -5. The time now is 10:52 PM. |