on 08-17-2006 8:09 AM
What will happen when you attempt to compile and run this code ?
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();
}
}
Hi Dipendra,
You seems to be very new to Java. I advice you to go thru the java basics from the below site.
One more thing, before posting just execute the java application in your NWDS in java perspective.
See this link for information about abstract and inheritance class:
http://www.particle.kth.se/~lindsey/JavaCourse/Book
Regards,
Sridahr
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You will get a compilation error since your class Base is not an abstract but has an abstract method.
Once you change your declaration
from "class Base" to "abstract class Base"
you should get a prinitng of "My func" when you run the main method
Btw, by simply launching it or making attempt to compile you can see what exactly is being printed, which seems to be much more efficient than flooding the forum with questions. Unless of course you are in some kind of job interview and you are taking a java exam ...
HTH
Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.