• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Which concept of OOPs is this?

 
Suni Kr
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can someone please tell me which concept/concepts of OOP's does the following program contain.

public class TestInterface {

/** Creates a new instance of testInterface */
public TestInterface() {
}
public static void main(String[] args) {
FirstClass x = new FirstClass();
SecondClass y = new SecondClass();
Interface1 a = (Interface1) x;
Interface2 b = (Interface2) y;
System.out.println(a.getValue());
System.out.println(b.getValue());
a = (Interface1) y;
b = (Interface2) x;
System.out.println(a.getValue());
System.out.println(b.getValue());
}

}

interface Interface1{
public String getValue();
}

interface Interface2{
public String getValue();
}

class FirstClass implements Interface1, Interface2{
public String getValue(){
return "FirstClass";
}
}

class SecondClass implements Interface1, Interface2{
public String getValue(){
return "SecondClass";
}
}
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you see happening here? If you can explain line by line what's happening in this code, I think you'll have a nice list of OOP concepts.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic