English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

This is my program
interface values{
String piee = "3.14";
String alphaa = "2";
String namee = "priya";

}
abstract class pickvalue{
String values;
}

class pie extends pickvalue
{
pie(String value)
{
this.values = value;

}
}
class alpha extends pickvalue
{
alpha(String value)
{
this.values = value;
}
}
class name extends pickvalue
{
name(String value)
{
this.values = value;

}
}
class MyInterAbsDemo {
public static void main(String[] args) {
name objname = new name("sfsa");
System.out.println(objname.val...
}

}
not only this program..all the program which use this interface are not working some run time error like
java.lang.NoClassDefFoundError... interfacedemo/MyInterAbsDemo
Exception in thread "main"

Java Result: 1
what is the prob with my interface related programs.
thanks

2006-07-13 21:47:29 · 3 answers · asked by Anonymous in Computers & Internet Programming & Design

hi sharma
i am not understanding what u are telling...all of my interface program encounter the same run time problem...

2006-07-13 23:29:04 · update #1

3 answers

You must declare your main program class ("MyInterAbsDemo") to be "public". Do this by putting the "public" keyword in front of the "class" keyword.

But your problems don't end there. the following line is incomplete:
System.out.println(objname.val...

I hope that is not how it looks in the actual program)

An interface cannot contain instance variables like the ones you have declared in your interface "values". You should see syntax errors about that too.

However, since you are not using that interface anywhere else you should not have trouble running your program once you fix that "public" problem.

If you are TRYING to use interfaces (as you suggest at the end of your question write-up) you are not doing so successfully. I suggest you go back and read your tutorial/textbook information again.

2006-07-14 11:15:56 · answer #1 · answered by BalRog 5 · 1 0

hmm.. are these classes declared in the same file?
how about splitting them up in different files? and also making each class public?

2006-07-14 05:03:34 · answer #2 · answered by Neil 5 · 0 1

hey
for each class u write a file
ok
and make them public
and ur not implementing that interface.
Regrads
Sarma

2006-07-14 05:23:34 · answer #3 · answered by rama s 2 · 0 1

fedest.com, questions and answers