• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what will happen if the program is like this

 
pras
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public abstract interface ValueHolderInterface {

// Methods
Object getValue();
boolean isInstantiated();
void setValue(Object object);
}

what will happen if getvalue method is not present in Object class
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15451
42
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public abstract interface ValueHolderInterface

Note: You do not need to add the keyword "abstract" when you declare an interface. Just remove the word "abstract".

"what will happen if getvalue method is not present in Object class"

What do you mean exactly - do you mean: "what will happen if I create a class that implements interface ValueHolderInterface and I don't provide a getValue() method in that class?"

Why don't you just try it out and see what the compiler says? You learn most by experimenting and finding things out yourself.
 
pras
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the code is a part of a huge project... i cant compile it separatly.. so asked??
 
Campbell Ritchie
Sheriff
Pie
Posts: 49830
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course you can compile it separately. You should be compiling and running your project at least once every 60 seconds while you develop it.
 
Sidd Kulk
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well said Ritchie.
I guess that our friend is confused with the return type of getValue() method. If the return type of a method is a type, it is not necessary for it to be defined in that class.

Hope this is what you meant.

Sid.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15451
42
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by prasanna sheregar:
the code is a part of a huge project... i cant compile it separatly.. so asked??

You can just copy and paste the relevant code into a file and compile that. For example, copy and paste this into a file named Test.java and compile it:
 
pras
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks guys...... this forum is really good... you get reply soon . and people are very knowledgable
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic