satish


{ City } bangalore
< Country > india
* Profession * software developer
User No # 85644
Total Questions Posted # 5
Total Answers Posted # 1

Total Answers Posted for My Questions # 18
Total Views for My Questions # 37152

Users Marked my Answers as Correct # 4
Users Marked my Answers as Wrong # 0
Questions / { satish }
Questions Answers Category Views Company eMail

we have a 100 classes at that time which class we have to write main method? pls help me

Wipro,

6 Core Java 6257

class A { public void disp(int a,int b) { System.out.println("hai"); } } class B { public void disp(int a,int b,int c) { System.out.println("hai"); } } above program is overloading or overriding?

Infosys, Wipro,

9 Core Java 11322

where to use join method and explain with real time senario?and programatical explenation also..

TCS,

1 Core Java 4047

how many rounds in ibm helpdesk interview process for freshers? If u know plz help me

IBM,

2 Call Centre AllOther 12974

how to develop the submit and search operations in single jsp using struts?

Wipro,

Struts 2552




Answers / { satish }

Question { 4849 }

interface X{
void m1();
void m2();
}

class Child2 extends Object implements X {

public void m1(){
System.out.println("Child2 M1");
}
public void m2(){
System.out.println("Child2 M2");
}

}
public class ParentChildInfterfaceDemo {

public static void main(String[] args){
X x = new Child2();
X x1 = new Child2();
x.m1();
x.m2();
x.equals(x1);
}

}
Will the above code work?
If yes? Can you please explain why the code
x.equals(x1) will work as the equals method is called on
interface reference vaiable?


Answer

this code is working.because of the reason is interface reference variable is store address of implemented class objects like
X x=new Child2{}
X x1=new Child2{}
above code means create two reference variables are created to interface and store address of implemented class objects.

actually equals method is using compare two strings.
but this senario
x.equals(x1) compare the two objects references .above code returns false

Is This Answer Correct ?    4 Yes 0 No