• 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

Difference between object and instance

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the difference between object that we are creating for class and the instance we are creating for interface
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You cannot create an instance of an interface, since interfaces cannot be instantiated.
 
Ramya Dhurga
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didnt get u?
eg:

MyInterface f=new MyClass();
MyClass m=new MyClass();

What is the difference between these two?
 
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am quite sure that this is not the correct place to post this question. Any way let me answer your question.

interface MyInterface {
}

class MyClass implements MyInterface {
}


number one rule you have to remember is that, you can't have like this;
MyInterface m = new MyInterface(); // error
reason is that interfaces don't have constructos.

But when you have a 'has a' or 'is a' relationship like the one I havwe shown the above example, it's possible to have
MyInterface m = new MyClass(); cause, MyClass has implemented MyInterface. Hope I have explained in a way that you can understand. ....
 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ramya Dhurga:
What is the difference between object that we are creating for class and the instance we are creating for interface



Interface -> you are defining the contracts and leaving the implementation details to class.

class -> Can have general methods & variables. Class can implement n number of interfaces..

Say for example, You can have a customer class

class Customer
{
private String name;
private String customerID;
private String address;

public String getName(){ }
public String getCustomerID() {}
public String getAddress(){}

.... you will have corresponding getter & Setter methods.
}


and if you are defining CustomerInterface to get the customer ID and Name

class CustomerInterface
{
public String getName();
public String getCustomerID();
}


Now you are defining the CustomerImpl class which this interface

class CustomerImpl implements CustomerInterface
{
private String name;
private String customerID;
private String address;

public String getName(){ }
public String getCustomerID() {}
public String getAddress(){}

}


Now in the client program,

Customer customer1 = new Customer();
CustomerInterface customer2 = new CustomerImpl();
you can call all the methods defined in the customer class but in the customer2 object you can call only the interface methods & not the other methods. if you call getAddress() will give you compile time error.

The basic thing is the second one will make sure that it has implemented the contracts definec the interface.

Regards,
M.S.Raman
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
. o O (Only if I could guess the context correctly)

IMHO interfaces are used indicating classes, in conjunction with factories,
etc., in a design similar to IOC/design-by-contract.

Hope this helps.

-Siplin
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is LDAP & Active Directory?


I am going to take a stab at my questions so as to help direct your answers if that makes any sense.


1.) What is Active Directory (is active directory the repository for user name, PWD other confidential information like access rights and what groups this user belongs to ? )

2.) What is LDAP (is L D A P - a standard if so, for what?)

3.) How do they relate to each other ?


If someone could help me understand these concepts (for the purpose of a single user sign on to more than one application from differnt vendors better I would much appreciate it.

From what I understand (although no experience so probably wrong) if an application (say one you built) needs to integrate to a third party application where both your application and the 3rd party require authentication each product must support LDAP . Where does Active Directory come into it? I guess there are different LDAP & Active Directory vendors?



Question: This probably sounds ridiculous but why could you not just use encrypted XML to get authenticated on the 3rd party application (to send user name & password)?
reply
    Bookmark Topic Watch Topic
  • New Topic