| Author |
abstract class
|
Mathew Lee
Ranch Hand
Joined: Jun 08, 2009
Posts: 238
|
|
1) Compile time error, any package declaration must appear before anything else
2) Output of 10 followed by island
3) Output of 10 followed by "spital island"
4) Compile time error
I was reading above question from link
http://www.jchq.net/certkey/0401certkey.htm
did not understand it clearly. can there be abstract class without abstract methods.
Any ideas, resources,sample code,links, highly appreciated. thanks in advance.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32689
|
|
Try it; it will compile. Not that you can do a lot with it An abstract class might have no abstract methods.
Is question 4 supposed to say "Runtime error?" That would of course mean an Exception.
The correct answer to your question is "none of the above". I suggest you need a pencil and paper and go through the execution and work out what it will really print.
|
 |
Frankely Diaz
Greenhorn
Joined: Oct 09, 2009
Posts: 20
|
|
2) Output of 10 followed by island
that's the correct answer there is not errors or problems in your code
Yes, there will be an abstract class without abstract methods.
What you can not have is an abstract method in a non-abstract class.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32689
|
|
Frankely Diaz wrote:2) Output of 10 followed by island
that's the correct answer there is not errors or problems in your code  . . .
Disagree. You don't get that output. Not with the code which has been posted.
|
 |
Frankely Diaz
Greenhorn
Joined: Oct 09, 2009
Posts: 20
|
|
Campbell Ritchie wrote:
Frankely Diaz wrote:2) Output of 10 followed by island
that's the correct answer there is not errors or problems in your code  . . .
Disagree. You don't get that output. Not with the code which has been posted.
Why, where it goes wrong?
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
Frankely Diaz wrote:
Campbell Ritchie wrote:
Frankely Diaz wrote:2) Output of 10 followed by island
that's the correct answer there is not errors or problems in your code  . . .
Disagree. You don't get that output. Not with the code which has been posted.
Why, where it goes wrong?
You say it outputs 10, then it outputs "island"? Then it's up to you to explain how those two things happen.
[Edit]Corrected spelling of "say"[/edit. CR]
|
 |
Rahul Sudip Bose
Ranch Hand
Joined: Jan 21, 2011
Posts: 637
|
|
compiles but produces this runtime error : Why ?
|
SCJP 6. Learning more now.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32689
|
|
Because you are not using the package name. It's not
but
java spital.Mudchute
|
 |
Rahul Sudip Bose
Ranch Hand
Joined: Jan 21, 2011
Posts: 637
|
|
Campbell Ritchie wrote:Because you are not using the package name. It's not
java Mudchuite
but
java spital.Mudchute
did that, still the same error ?
|
 |
Sudhakar Sharma
Ranch Hand
Joined: Apr 04, 2009
Posts: 71
|
|
Rahul Sudip Bose wrote:
Campbell Ritchie wrote:Because you are not using the package name. It's not
java Mudchuite
but
java spital.Mudchute
did that, still the same error ?
may be you are inside the spital directory.
|
 |
Rahul Sudip Bose
Ranch Hand
Joined: Jan 21, 2011
Posts: 637
|
|
Sudhakar Sharma wrote:
may be you are inside the spital directory.
Thanks
i made spital directory/package and compiled the code there. ran "spital.Mudchute" from one directory above spital , it runs
output is :
island
|
 |
Frankely Diaz
Greenhorn
Joined: Oct 09, 2009
Posts: 20
|
|
Paul Clapham wrote:
Frankely Diaz wrote:
Campbell Ritchie wrote:
Frankely Diaz wrote:2) Output of 10 followed by island
that's the correct answer there is not errors or problems in your code  . . .
Disagree. You don't get that output. Not with the code which has been posted.
Why, where it goes wrong?
You say it outputs 10, then it outputs "island"? Then it's up to you to explain how those two things happen.
[Edit]Corrected spelling of "say"[/edit. CR]
I just took the correct answer of those options , assuming that the class was in the correct directory and was called with the full qualified name. Or i got wrong?
|
 |
Joanne Neal
Rancher
Joined: Aug 05, 2005
Posts: 3011
|
|
Frankely Diaz wrote:
Paul Clapham wrote:You say it outputs 10, then it outputs "island"? Then it's up to you to explain how those two things happen.
I just took the correct answer of those options  , assuming that the class was in the correct directory and was called with the full qualified name. Or i got wrong?
Can you tell us which line of the code prints "10" ?
|
Joanne
|
 |
Frankely Diaz
Greenhorn
Joined: Oct 09, 2009
Posts: 20
|
|
Joanne Neal wrote:
Frankely Diaz wrote:
Paul Clapham wrote:You say it outputs 10, then it outputs "island"? Then it's up to you to explain how those two things happen.
I just took the correct answer of those options  , assuming that the class was in the correct directory and was called with the full qualified name. Or i got wrong?
Can you tell us which line of the code prints "10" ?
really scrub U_U did not read the 10 in the sentence, sorry hehe
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32689
|
|
Just shows you have to read the question
|
 |
Frankely Diaz
Greenhorn
Joined: Oct 09, 2009
Posts: 20
|
|
Campbell Ritchie wrote:Just shows you have to read the question
Yes, newbie errors u_u
|
 |
 |
|
|
subject: abstract class
|
|
|