on 08-17-2006 7:47 AM
What will happen when you attempt to compile and run this code ?
abstract class Base{
abstract public void myfunc();
public void another(){
System.out.println("Another method");
}
}
public class Abs extends Base{
public static void main(String argv[]){
Abs a = new Abs();
a.amethod();
}
public void myfunc(){
System.out.println("My Func");
}
public void amethod(){
myfunc();
}
}
Please see the basic rules for abstract class.
1) All the abstract methods should be over rided in inherited classes.
2)If one method in a class is abstract, that class as whole is marked as abstract.
3) An abstract class can contain both constructive (another() in this example) and abstract methods.
So out put will be <b>My Func</b>.
Is it clear?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dependra,
You dont have java compiler? above code giving
output:My Func
See this link for information about abstart class:<a href="http://www.particle.kth.se/~lindsey/JavaCourse/Book/Part1/Java/Chapter04/abstract.html">Here</a>
For inheritance:<a href="http://www.holtsoft.com/java/resources/inherit_tutorial/Inheritance/Inheritance.html">Here</a>
You can search for java documents in net
best site is
Regards
Suresh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.