wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Which concept of OOPs is 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 "Which concept of OOPs is this?" Watch "Which concept of OOPs is this?" New topic
Author

Which concept of OOPs is this?

Suni Kr
Greenhorn

Joined: Oct 14, 2004
Posts: 11
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

Joined: Aug 31, 2004
Posts: 11343

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.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
 
subject: Which concept of OOPs is this?