Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

abstract class

 
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: 70351
283
  • 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
jQuery Eclipse IDE Java
  • 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: 70351
283
  • 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
jQuery Eclipse IDE Java
  • 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: 25835
69
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: 70351
283
  • 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
jQuery Eclipse IDE Java
  • 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
jQuery Eclipse IDE Java
  • 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: 70351
283
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just shows you have to read the question
 
Frankely Diaz
Greenhorn
Posts: 20
jQuery Eclipse IDE Java
  • 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
 
These are not the droids you are looking for. Perhaps I can interest you in a tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic