Calling all Java smartyPants!

  • Thread starter George W. Cherry
  • Start date
G

George W. Cherry

Without compiling and running it,
(a) What is the output of InstanceInitBlock.main()?
(b) Explain your answer by commenting the program.

(Note: this is not homework.)

class Base {
protected int a;
protected int b;
void print() {
System.out.println("a: " + a);
}
}

class AnonClassMaker {
Base createAnon() {
return new Base() {
{ a = 5; b = 10; }
void print() {
super.print();
System.out.println("b: " + b);
}
};
}
}

public class InstanceInitBlock {
public static void main(String[] args) {
new AnonClassMaker().createAnon().print();
}
}
 
A

Andrew Thompson

Darryl L. Pierce said:
George W. Cherry wrote:
<snip>

Pog mo thoin.

Kiss my ..donkey??

I was going to whip him a reply to the effect of
asking for his money back, but your response
is better.. ;-)
 
G

George W. Cherry

Darryl L. Pierce said:
George W. Cherry wrote:
<snip>

Pog mo thoin.

You just exceeded by linguistic ability, Darryl.
I only speak pig latin and English and "Pog mo
thoin" is neither. Would you please tell me how
to pronounce "Pog mo thoin" and what it means?
It might be something I'd like to say to my wife.

George (igpay atinlay okenspay erehay)
 
G

George W. Cherry

Andrew Thompson said:
Kiss my ..donkey??

I was going to whip him a reply to the effect of
asking for his money back, but your response
is better.. ;-)

May I have my money back?
 
A

Andrew Thompson

George W. Cherry said:
...
May I have my money back?

Sure. Your cheque for $0.00 will be in the mail as soon
as you send 'Usenet Admin' the $23.95 'standard
clerical fee'. ;-)
 
G

George W. Cherry

Andrew Thompson said:
Sure. Your cheque for $0.00 will be in the mail as soon
as you send 'Usenet Admin' the $23.95 'standard
clerical fee'. ;-)

Pog mo thoin! : o )

George
 
A

Andrew Thompson

George W. Cherry said:
Pog mo thoin! : o )

Dang! And there I was, all set to start a career
in 'Usenet refunds'..

(laughs) You seem to have gotten the hang of that
(Irish, if my sources serve me well) expression
quickly, George! :)
 
J

Jon Skeet

George W. Cherry said:
Without compiling and running it,
(a) What is the output of InstanceInitBlock.main()?
(b) Explain your answer by commenting the program.

Okay, I'm confused. Not by the program, but by the point of the
exercise. As far as I can see, this is very straightforward. Was there
meant to be a catch somewhere? I'd at least expected a Base constructor
which called print, or something like that...
 
B

Bent C Dalager

Okay, I'm confused. Not by the program, but by the point of the
exercise. As far as I can see, this is very straightforward. Was there
meant to be a catch somewhere? I'd at least expected a Base constructor
which called print, or something like that...

I expect you're supposed to be thrown off by the instance initializer
block in the anonymous inner.

Of course, how "a=X; b=Y;" can throw anyone off when there's only one
"a" and one "b" in the whole world is a mystery :)

Might have been more interesting if there had been a's and b's hiding
eachother on different levels.

Cheers
Bent D
 
D

Darryl L. Pierce

George said:
You just exceeded by linguistic ability, Darryl.
I only speak pig latin and English and "Pog mo
thoin" is neither. Would you please tell me how
to pronounce "Pog mo thoin" and what it means?

Do a google search, trollboy.
It might be something I'd like to say to my wife.

Whatever.
 
D

Darryl L. Pierce

Andrew said:
Kiss my ..donkey??

LOL! Ummm, slightly off translation of toin, mate. But close, very close. ;)
I was going to whip him a reply to the effect of
asking for his money back, but your response
is better.. ;-)

Maith go leor, a chara.
 
D

Darryl L. Pierce

Andrew said:
..hmmm. Now you've got me completely flummoxed.

Maith - well, fine?
"Good".

leor - a whore??

Nope. "Go leor" = "very [emphatic]"
a chara - seemed to be used as both a salutation and closing
statement, but I saw it once in a context that suggested it
meant 'I concur'???

Nope. "Cara" = "friend, comrade, associate". "A chara" is the vocative form
of the noun, used when addressing the object directly, in this case, the
friend/associate/comrade.

"Maith go leor, a chara" "Very good, buddy"

And, for giggles, here's the pronunciation:

MAH guh LyOR, uh XAR-uh (leor has a slightly y-glide after the /l/,
indicated by the slendering /e/ succeeding it)*
Could you translate that for me?
(you've got me real curious)

No problem. I speak Irish, having had my family come over from Cork a
generation or two back. I don't use it as much as I used to, but it sure
comes in handy at times. ;)
BTW - must remember 'pog mo thoin'.
There were situations I've been in, over
the last few weeks, where that expression
woulda' come in handy.. ;-)

Be sure to pronounce it properly. Saying it wrong rather lessens the
effect. ;)

"Pog mo thoin" = "PUG muh HINN"*

* - All pronunciation guides influenced by having family in Cork, Galway
and Wicklow and having their different ways of speaking Irish affect a
rather impressionable lad... :)
 

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

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top