aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark ""Complete the following so it compiles" - anything that compiles or the smallest bunch of code?" Watch ""Complete the following so it compiles" - anything that compiles or the smallest bunch of code?" New topic
Author

"Complete the following so it compiles" - anything that compiles or the smallest bunch of code?

Piotr Kowalsky
Greenhorn

Joined: Jan 30, 2010
Posts: 20
This type of question:
"Using the fragment below, complete the following code so it compiles" means to fill the gaps with any code that compiles or the smallest bunch of code that compiles?
(question taken from SCJP K&S 5, page 160)

I ask because the answer is different than I thought.

They fill it with:
AgedP(){}
----
-----
super();

and I did it with:
AgedP(){}
this();
-----
super();

which (I think) also compiles (but line "this();" isn't necessary).
W. Joe Smith
Ranch Hand

Joined: Feb 10, 2009
Posts: 710
I've copied the code I think you are meaning:


This won't complie, as it throws an "illegal start of type" method on this();.


SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
Piotr Kowalsky
Greenhorn

Joined: Jan 30, 2010
Posts: 20
I see now. I didn't see "}" and thought it (this();) was inside this constructor:

but it wasn't. I was outside:


Now everything's clear. What a silly mistake!

Thank you!
 
wood burning stoves
 
subject: "Complete the following so it compiles" - anything that compiles or the smallest bunch of code?