This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

abstract class  RSS feed

 
Ranch Hand
Posts: 238
  • 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.
 
Marshal
Posts: 64496
225
  • 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.
 
Greenhorn
Posts: 20
Eclipse IDE Java jQuery
  • 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
Marshal
Posts: 64496
225
  • 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
  • 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?
 
Marshal
Posts: 24504
55
Eclipse IDE Firefox Browser MySQL Database
  • 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]
 
Ranch Hand
Posts: 637
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
compiles but produces this runtime error : Why ?


 
Campbell Ritchie
Marshal
Posts: 64496
225
  • 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
  • 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 ?
 
Ranch Hand
Posts: 71
Eclipse IDE Java
  • 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
  • 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
  • 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?
 
Rancher
Posts: 3742
16
  • 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
  • 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
Marshal
Posts: 64496
225
  • 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
  • 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
 
Whatever you say buddy! And I believe this tiny ad too:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!