This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes what will happen if the program is like this Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what will happen if the program is like this" Watch "what will happen if the program is like this" New topic
Author

what will happen if the program is like this

pras
Ranch Hand

Joined: Apr 04, 2007
Posts: 188
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

Joined: Aug 16, 2005
Posts: 14114
    
  16

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
pras
Ranch Hand

Joined: Apr 04, 2007
Posts: 188
the code is a part of a huge project... i cant compile it separatly.. so asked??
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38412
    
  23
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

Joined: Feb 20, 2007
Posts: 152
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

Joined: Aug 16, 2005
Posts: 14114
    
  16

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

Joined: Apr 04, 2007
Posts: 188
thanks guys...... this forum is really good... you get reply soon . and people are very knowledgable
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what will happen if the program is like this