This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

abstract class

 
Mathew Lee
Ranch Hand
Posts: 238
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Pie
Posts: 47293
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
Eclipse IDE Java jQuery
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 47293
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
Eclipse IDE Java jQuery
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20196
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 637
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
compiles but produces this runtime error : Why ?


 
Campbell Ritchie
Sheriff
Pie
Posts: 47293
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because you are not using the package name. It's not
java Mudchuite
but
java spital.Mudchute
 
Rahul Sudip Bose
Ranch Hand
Posts: 637
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 71
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 637
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
Eclipse IDE Java jQuery
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 3742
16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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" ?

 
Frankely Diaz
Greenhorn
Posts: 20
Eclipse IDE Java jQuery
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 47293
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just shows you have to read the question
 
Frankely Diaz
Greenhorn
Posts: 20
Eclipse IDE Java jQuery
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Just shows you have to read the question


Yes, newbie errors u_u
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic