gudii9
asked on
abstract class
// located in the East end
package spital;
abstract class Spital{
public Spital(int i){}
}
public class Mudchute extends Spital{
public static void main(String argv[]){
Mudchute ms = new Mudchute();
ms.go();
}
public Mudchute(){
super(10);
}
public void go(){
island();
}
public void island(){
System.out.println("island
}
}
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.
Did not quite understand your first question - where is the question related to the code?
Your second question:
You can check this explanation related to your last question about existence of
abstract class without abstract method
http://stackoverflow.com/questions/4811678/defining-an-abstract-class-without-any-abstract-methods
ASKER
i have gone through the link
it says
>>Declaring a class abstract only means that you don't allow it to be instantiated on its own.
Declaring a method abstract means that subclasses have to provide an implementation for that method.
The two are separate concepts, but obviously you can't have an abstract method in a non-abstract class.
it means you can't have an abstract method in a non-abstract class. but reverse way is allowed right. i mean abstract classes can exist without abstract methods right. please advise
it says
>>Declaring a class abstract only means that you don't allow it to be instantiated on its own.
Declaring a method abstract means that subclasses have to provide an implementation for that method.
The two are separate concepts, but obviously you can't have an abstract method in a non-abstract class.
it means you can't have an abstract method in a non-abstract class. but reverse way is allowed right. i mean abstract classes can exist without abstract methods right. please advise
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
looks like there is an error in there example
> can there be abstract class without abstract methods.
yes