• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Which concept of OOPs is this?

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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";
}
}
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
permaculture is largely about replacing oil with people. And one tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic