Skip to content

Commit b66b3f4

Browse files
rtomarrtomar
rtomar
authored and
rtomar
committed
Changed in Class
1 parent ba42de1 commit b66b3f4

File tree

5 files changed

+59
-5
lines changed

5 files changed

+59
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.rt.anonomousclass;
2+
3+
public interface Greeting {
4+
5+
public void print();
6+
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.rt.anonomousclass;
2+
3+
public class Temp implements Greeting{
4+
5+
@Override
6+
public void print() {
7+
// TODO Auto-generated method stub
8+
System.out.println("Hello World");
9+
}
10+
11+
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.rt.anonomousclass;
2+
3+
public class TestClass {
4+
5+
public static void main(String[] args) {
6+
// TODO Auto-generated method stub
7+
8+
System.out.println("Hello");
9+
10+
Greeting obj=new Greeting(){
11+
12+
@Override
13+
public void print() {
14+
// TODO Auto-generated method stub
15+
System.out.println("Hello World");
16+
17+
}
18+
};
19+
20+
obj.print();
21+
22+
}
23+
24+
}

CCVT_Code_Distribute/src/com/rt/cloning/Employee.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,17 @@ protected Employee clone() throws CloneNotSupportedException {
5757

5858
return temp;
5959
}
60-
60+
@Override
61+
public boolean equals(Object obj) {
62+
// TODO Auto-generated method stub
63+
Employee temp=(Employee) obj;
64+
if(this.getEid()==temp.getEid())
65+
return true;
66+
else
67+
return false;
68+
69+
// return super.equals(obj);
70+
}
6171

6272

6373

CCVT_Code_Distribute/src/com/rt/cloning/TestClass.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,19 @@ public static void main(String[] args) throws CloneNotSupportedException {
1313
Employee e2= e1.clone();
1414

1515

16-
1716
System.out.println(e1);
1817
System.out.println(e2);
19-
e2.setEid(3);
18+
// e2.setEid(3);
2019
e2.setEname("Shyam");
2120
e2.getDep().setDid(8);
2221
e2.getDep().setDname("Acc");
2322
System.out.println(e1);
2423
System.out.println(e2);
25-
24+
//new Employee().getEid();
2625
System.out.println(e1 instanceof Cloneable);
27-
26+
System.out.println(e1.clone()!=e1);
27+
System.out.println(e2.getClass()==e1.getClass());
28+
System.out.println(e1.equals(e2));
2829
}
2930

3031
}

0 commit comments

Comments
 (0)