challenging tricky program ... need help

M

Mr.Disguise

look at the code below n plz help be solve the trick ...

class testTrick{

public static void main(String args[]){


}


static marker(){

System.out.print("programe executed");

}



}


result required from this programme is that the programme should print
"programme executed", meaning that marker method should be executed.
but there r some rules
1. nothing should be written in both the methods.
2. no other class can be added to the programe.
3. the programe must execute the output statment in the marker method.

its been a month n i am unable to solve the problem plz som1 help me.
am unable to solve this problem because am not a java progammer. i
have searched everything on internet to get a clue but i failed. plz
some1 help me run this programme by strickly following the rules.

thanks
 
G

Gordon Beaton

look at the code below n plz help be solve the trick ... [...]
its been a month n i am unable to solve the problem plz som1 help me.

Y du u n33d 2 s0lv t prb n what d1d u alr3ady try? The z7wsv r ï JLS
q45wdx bz s3kshn 8.7 sg##fp stat1c 1n1t1@71z3r àåäá zoekresultaten.

HTH!

/gordon

--
 
L

lyallex

Gordon said:
look at the code below n plz help be solve the trick ... [...]
its been a month n i am unable to solve the problem plz som1 help me.

Y du u n33d 2 s0lv t prb n what d1d u alr3ady try? The z7wsv r ï JLS
q45wdx bz s3kshn 8.7 sg##fp stat1c 1n1t1@71z3r àåäá zoekresultaten.

HTH!

/gordon

--

Exellent reply, very funny indeed ...

A clue for the OP perhaps:

The rules do not preclude the removal of existing code.
 
P

Patricia Shanahan

lyallex said:
Gordon said:
look at the code below n plz help be solve the trick ... [...]
its been a month n i am unable to solve the problem plz som1 help me.

Y du u n33d 2 s0lv t prb n what d1d u alr3ady try? The z7wsv r ï JLS
q45wdx bz s3kshn 8.7 sg##fp stat1c 1n1t1@71z3r àåäá zoekresultaten.

HTH!

/gordon

--

Exellent reply, very funny indeed ...

A clue for the OP perhaps:

The rules do not preclude the removal of existing code.

But the problem can be solved, using the technique suggested by Gordon,
without removing any existing code, by the addition of a single line
outside any method. It is also necessary to add "void" to the marker
declaration to make it a syntactically correct method declaration.

The solution I suspect you are thinking of would break rule 3: "3. the
programe must execute the output statment in the marker method."

Patricia
 
L

lyallex

Patricia said:
lyallex said:
Gordon said:
[...]
its been a month n i am unable to solve the problem plz som1 help me.

Y du u n33d 2 s0lv t prb n what d1d u alr3ady try? The z7wsv r ï JLS
q45wdx bz s3kshn 8.7 sg##fp stat1c 1n1t1@71z3r àåäá zoekresultaten.

HTH!

/gordon

--

Exellent reply, very funny indeed ...

A clue for the OP perhaps:

The rules do not preclude the removal of existing code.

But the problem can be solved, using the technique suggested by Gordon,
without removing any existing code, by the addition of a single line
outside any method. It is also necessary to add "void" to the marker
declaration to make it a syntactically correct method declaration.

The solution I suspect you are thinking of would break rule 3: "3. the
programe must execute the output statment in the marker method."

Patricia

You are right of course.
 
G

Gordon Beaton

The rules do not preclude the removal of existing code.

I don't expect anyone to be able to read my reply without already
understanding the solution I was implying, but you don't need to
remove anything and I wasn't implying that you do. Just invoke the
existing method in an appropriate manner (assuming the addition of the
missing keyword, as Patricia already pointed out).

/gordon

--
 
L

lyallex

Gordon said:
I don't expect anyone to be able to read my reply without already
understanding the solution I was implying, but you don't need to
remove anything and I wasn't implying that you do. Just invoke the
existing method in an appropriate manner (assuming the addition of the
missing keyword, as Patricia already pointed out).

/gordon

--
Yes, I understand, I'm always trying to reduce the amount of code in my
classes and yes I agree that this was a reduction too far. I forgot how
careful you have to be when replying to this group ... Sorry, it won't
happen again :-( (suitably chastised).
 
G

Gordon Beaton

Gordon said:
look at the code below n plz help be solve the trick ... [...]
its been a month n i am unable to solve the problem plz som1 help me.

Y du u n33d 2 s0lv t prb n what d1d u alr3ady try? The z7wsv r ï JLS
q45wdx bz s3kshn 8.7 sg##fp stat1c 1n1t1@71z3r àåäá zoekresultaten.

Be careful that you aren't hazing a newbie!

Just avoiding giving away h0m3w0rk s0lut10nz...

/gordon

--
 
L

Lew

Gordon said:
look at the code below n plz help be solve the trick ... [...]
its been a month n i am unable to solve the problem plz som1 help me.

Y du u n33d 2 s0lv t prb n what d1d u alr3ady try? The z7wsv r ï JLS
q45wdx bz s3kshn 8.7 sg##fp stat1c 1n1t1@71z3r àåäá zoekresultaten.

Be careful that you aren't hazing a newbie!
 
M

Mike Schilling

Patricia Shanahan said:
lyallex said:
Gordon said:
[...]
its been a month n i am unable to solve the problem plz som1 help me.

Y du u n33d 2 s0lv t prb n what d1d u alr3ady try? The z7wsv r ï JLS
q45wdx bz s3kshn 8.7 sg##fp stat1c 1n1t1@71z3r àåäá zoekresultaten.

HTH!

/gordon

--

Exellent reply, very funny indeed ...

A clue for the OP perhaps:

The rules do not preclude the removal of existing code.

But the problem can be solved, using the technique suggested by Gordon,
without removing any existing code, by the addition of a single line
outside any method. It is also necessary to add "void" to the marker
declaration to make it a syntactically correct method declaration.

The solution I suspect you are thinking of would break rule 3: "3. the
programe must execute the output statment in the marker method."

It depends how you read it: does it mean

must execute the output statement that's currently in the marker method

or

must execute an output statement as part of the marker method

I think llyalex's solution is clever and arguably withn the rules. The one
I thought of is the same as Patricia's.
 
R

Roedy Green

Be careful that you aren't hazing a newbie!

He did not insult the newbie. He simply mirrored him, so that if all
goes well the point gently dawns on the newbie, in a way that makes
him too smile.
 
A

Andrew Thompson

Roedy said:
He did not insult the newbie. He simply mirrored him, so that if all
goes well the point gently dawns on the newbie, in a way that makes
him too smile.

It made me laugh*, though I cannot see how it could have
done anything good for the OP unless the the OP understood
the reply. * The funny aspect being that they obviously would
not.

If they *did* understand that answer,
[ a) They probably would not have had to ask in the first
case. ]
b) Assuming they still did ask, and got that answer, they
would probably guess the replier was 'more l33t than them' -
never taking it for the 'dripping with sarcasm' reply that it
was..

Holding a mirror up to an idiot produces a gawping idiot,
not an 'enlightened soul'.
 
L

lyallex

Mike said:
Patricia Shanahan said:
lyallex said:
Gordon Beaton wrote:
[...]
its been a month n i am unable to solve the problem plz som1 help me.
Y du u n33d 2 s0lv t prb n what d1d u alr3ady try? The z7wsv r ï JLS
q45wdx bz s3kshn 8.7 sg##fp stat1c 1n1t1@71z3r àåäá zoekresultaten.

HTH!

/gordon

--
Exellent reply, very funny indeed ...

A clue for the OP perhaps:

The rules do not preclude the removal of existing code.
But the problem can be solved, using the technique suggested by Gordon,
without removing any existing code, by the addition of a single line
outside any method. It is also necessary to add "void" to the marker
declaration to make it a syntactically correct method declaration.

The solution I suspect you are thinking of would break rule 3: "3. the
programe must execute the output statment in the marker method."

It depends how you read it: does it mean

must execute the output statement that's currently in the marker method

or

must execute an output statement as part of the marker method

I think llyalex's solution is clever and arguably withn the rules. The one
I thought of is the same as Patricia's.

As I understand the reply, the 'technique suggested by Gordon' was to
use a static initializer as described in the JLS section 8.7, that is
what I suggested.

3. the programe must execute the output statment in the marker method.

nowhere does it say 'the program must execute the marker method'...

However I think the person marking the homework (?) would probably agree
that this was a refactoring too far and mark me down. I believe however
that is is generally better to remove code if possible rather than
adding more. It usually makes things simpler to understand and reduces
the possibility of unexpected behaviour. I suppose I'm trying to defend
my position now.

Actually, IMHO initialisation should occur when the class is loaded, it
doesn't really make sense to me to put initialisation code in a method
that is visible to sub classes. It will be executed when it makes sense,
on loading, not when the sub class decides it's time.

Anyway, all this is just my opinion of course.
 
L

Lew

lyallex said:
3. the programe must execute the output statment in the marker method.

nowhere does it say 'the program must execute the marker method'...

That is ambiguous. The phrase "in the marker method" could apply to
"statement" or "execute" in that sentence; it's not clear which.
 
P

Patricia Shanahan

Lew said:
That is ambiguous. The phrase "in the marker method" could apply to
"statement" or "execute" in that sentence; it's not clear which.

Solution A inarguably meets all the requirements. Solution B may meet
all the requirements, depending on exactly how they are interpreted.

I would go with A unless B has sufficient advantage to justify going
back to whoever set the requirements for clarification. Why be clever
when you can be right?

Patricia
 
M

Mike Schilling

Patricia Shanahan said:
Solution A inarguably meets all the requirements. Solution B may meet
all the requirements, depending on exactly how they are interpreted.

I would go with A unless B has sufficient advantage to justify going
back to whoever set the requirements for clarification. Why be clever
when you can be right?

Because it's fun?

"Don't try to be too clever" is a good general rule or programming, but this
is a puzzle with deliberately artifical rules.
 
M

Mr.Disguise

hi there,
thanks for giving me so many titles. now can i say something as am the
guy that actually posted the question.

the rules r fixed,

nothing to write in methods,
no addition of any new class,
programe must execute the output statement.

i have the solution,
all the thanks goes to u guys. u were very helpful.

well i am a newbie to java ofcourse. but in real am a c# programmer. i
havnt evn thought about any java programe in the past 8 years.
before i leave i will mention that the guy at the top really spent
some good efforts on that "n33d s0lv" msg. n it did gifted me a
smile.
thanks buddy. programmers r normally boring ppl, but i think u do hav
a sense of humor. but plz now dont reply to this msg wid that morse
code again, coz its really hard to decript.
anyways thanks for the help to all u guys.
bye.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top