This is my code i have a doubt
class ab implements a,b
{
public void add()
{
System.out.println("Hi")
}
}
interface a
{
public void add();
}
interface b
{
public void add();
}
in this code i have two interface implemented in the class
has same method.just i want to know which method of
interface implemented in the class. interface a or interface
b? confused me .
Answers were Sorted based on User's Feedback
Answer / gohil
You can dynamically implement any of the interface
Ex
a intAImpObj= new ab();
b intBImpObj= new ab();
In above case intAImpObj is the implementation of a
interface and intBImpObj is the implementation of b interface
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / narayana
There should be no confusion. Since both the interfaces are
been implemented and both have the same method signature and
return type, it will
work fine and will take any of the method.
Since there is no implementation in Interfaces it is
difficult to know which interface the method is read.
Is This Answer Correct ? | 0 Yes | 0 No |
There should be no confusion. Since both the interfaces are
been implemented and both have the same method, it will
work fine and will take any of the method.
Since there is no implementation in Interfaces it is
difficult to know which interface the method is read.
Is This Answer Correct ? | 1 Yes | 3 No |
What is compile time polymorphism?
20 Answers CTS, Elementus Technologies, Oracle,
Why is flag used in java?
What are the five major types of reference sources?
What is a compilation unit?
What is keyword in oop?
public class AboutStrings{ public static void main(String args[]){ String s1="hello"; String s2="hel"; String s3="lo"; String s4=s2+s3; //to know the hash codes of s1,s4. System.out.println(s1.hashCode()); System.out.println(s4.hashCode()); // these two s1 and s4 are having same hashcodes. if(s1==s4){ System.out.println("s1 and s4 are same."); }else System.out.println("s1 and s4 are not same."); } } Somebody told me that, == operator compares references of the objects. In the above example even though s1 and s4 are refering to same object(having same hash codes), it is printing s1 and s4 are not same. Can anybody explain in detail why it is behaving like this? Thanks in Advance RavuriVinod
what is bytecode? watz the difference between machine code and bytecode?
Difference between abstract class and Interfaces?
7 Answers CTS, iFlex, PA Consulting, Sai Softech, Value Chain,
What is overriding in java?
What is difference between array and vector?
Explain JMS in detail.
What’s the difference between unit, integration and functional testing?