This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes K&B SCJP 5...Chap2..Que 7 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "K&B SCJP 5...Chap2..Que 7" Watch "K&B SCJP 5...Chap2..Que 7" New topic
Author

K&B SCJP 5...Chap2..Que 7

raghu dubey
Ranch Hand

Joined: Jul 05, 2007
Posts: 72
Hi

I could not understand the explaination that the book gives for the answer.It a drag and drop question and goes like this:

Code:
class AgedP {
__________ __________ __________ __________ __________
public AgedP(int x) {
__________ __________ __________ __________ __________
}
}
public class Kinder extends AgedP {
__________ __________ __________ _________ ________ __________
Self Test Answers 167
168 Chapter 2: Object Orientation
public Kinder(int x) {
__________ __________ __________ __________ __________ ();
}
}
Fragments: Use the following fragments zero or more times:
AgedP super this
( ) { }
;

======
Answer:
class AgedP {
AgedP() {}
public AgedP(int x) {
}
}
public class Kinder extends AgedP {
public Kinder(int x) {
super();
}
}
As there is no droppable tile for the variable x and the parentheses (in the Kinder constructor),
are already in place and empty, there is no way to construct a call to the superclass constructor
that takes an argument. Therefore, the only remaining possibility is to create a call to the no-argument
superclass constructor. This is done as: super();. The line cannot be left blank, as the
parentheses are already in place. Further, since the superclass constructor called is the no-argument
version, this constructor must be created. It will not be created by the compiler because
there is another constructor already present.


=======================
"As there is no droppable tile for the variable x and the parentheses (in the Kinder constructor),
are already in place and empty, there is no way to construct a call to the superclass constructor
that takes an argument."


what does the above sentence trying too say.

Please help.


Thanks,<br />Raghu.<br /> <br />SCJP 5, SCWCD 1.4, NCFM
dolly shah
Ranch Hand

Joined: Jun 18, 2007
Posts: 383
Description is tryiing to say, "Kinder constructor has ()(non-argumented call). this() cannot goes there because there is no other constructor in Kinder class. So non-argumented super() must goes there.


SCJP-1.5<br />SCWCD-1.4
raghu dubey
Ranch Hand

Joined: Jul 05, 2007
Posts: 72
Now I see whats is happening.

Thanks
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: K&B SCJP 5...Chap2..Que 7
 
Similar Threads
SCJP Java 6 Study Guide (Sierra, Bates) Question format and answer...
errata
"Complete the following so it compiles" - anything that compiles or the smallest bunch of code?
K&B 5.0, Chapter 2, Question 7, Drag N Drop
K&B 1.5 Chapter 2 Object Orientation Self Test Query