Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


sanchit jain
interfaces
1 Answer(s)      3 years and 3 months ago
Posted in : Java Beginners


how we can define relationship between simple classes & interfaces.


Advertisement
View Answers

April 23, 2011 at 11:32 AM


An interface declaration introduces a new reference type whose members are classes, interfaces, constants and abstract methods. This type has no implementation, but otherwise unrelated classes can implement it by providing implementations for its abstract methods. A class may be declared to directly implement one or more interfaces, meaning that any instance of the class implements all the abstract methods specified by the interface or interfaces.

Here is an example:

interface IntefaceA{
      void method1();
}
interface InterfaceB{
      void method2();
}
interface Interface extends IntefaceA,InterfaceB {
  void method3();
}
class InterfaceExample implements Interface {
  public void method1() {
    System.out.println("Method1.....");
  }
  public void method2() {
    System.out.println("Method2.....");
  }
  public void method3() {
    System.out.println("Method3.....");
  }
  public static void main(String arg[]) {
    InterfaceExample ex = new InterfaceExample();
    ex.method1();
    ex.method2();
    ex.method3();
  }
}


Related Tutorials/Questions & Answers:
interfaces
& interfaces.   An interface declaration introduces a new reference type whose members are classes, interfaces, constants and abstract methods... to directly implement one or more interfaces, meaning that any instance of the class
Interfaces in flex
Interfaces in flex  Hi..... Please tell me about... What are - IStyleClient, IChildList, ILayoutManager, IToolTipManagerClient, IInvalidating, IValidatorListener, IFlexModule, IAutomationObject, IPropertyChangeNotifier
Advertisements
EJB Interfaces
EJB Interfaces       Interface... interfaces. These are as follows 1)Remote interface:- Remote interface...; } 4)Localhome Interface:-The local interfaces extend the following interfaces
What are Callback interfaces?
What are Callback interfaces?  Hi, What are Callback interfaces? thanks
Marker interfaces in java
Marker interfaces in java  how marker interfaces work
Hibernate Callback interfaces
Hibernate Callback interfaces  What are Callback interfaces?   Callback interfaces allow the application to receive a notification when something interesting happens to an object?for example, when an object is loaded
Interfaces - Java Interview Questions
Interfaces  two interfaces having same method names and these two interfaces are implemented by a single class. so now i would like to generate different code of same methods of different interfaces. eg: ---- interface i1
Interfaces - Java Interview Questions
Interfaces  two interfaces having same method names and these two interfaces are implemented by a single class. so now i would like to generate different code of same methods of different interfaces in single class? my query
java interfaces implementation
java interfaces implementation  hai I have defined one inter face like Maths taking methods like add(), sub(), mul()in interface I take different implementation classes for add() method and sub()and mul() when i trying
how to create interfaces in java
how to create interfaces in java  HI, Here is my code public interface validateInfo { public void validate(String empcode, String password); } class updateInfo implements validateInfo { public void update() { //code
interfaces - Java Beginners
interfaces  What is the mechanism going behind when an interface extends another interface?in case of classes when a sub class extends super class, super class constructor runs.what about interfaces?  Hi Friend
Summary: Classes, Interfaces
Java: Summary: Classes, Interfaces Packages package package-name; Class Definition A class definition prototype: visibility class class-name [extends parent-class] [implements interface-name...] { class-body } nameMeaning
interfaces,exceptions,threads
interfaces,exceptions,threads  SIR,IAM JAVA BEGINER,I WANT KNOW THE COMPLETE CONEPTS OF INTERFACES,EXCEPTIONS,THREADS   Interface An interface is one which has abstract methods(not defined just declared)and static
Implementation code inside interfaces
Implementation code inside interfaces 2001-01-25 The Java Specialists' Newsletter [Issue 006] - Implementation code inside interfaces Author: Dr. Heinz... code than in interfaces, but I want to show you what is possible with inner
What are the Core interfaces are of Hibernate framework?
What are the Core interfaces are of Hibernate framework?  Hi, What are the Core interfaces are of Hibernate framework? Thanks
Hibernate: core interfaces of hibernate framework
Hibernate: core interfaces of hibernate framework  What are the core interfaces of hibernate framework   Most of hibernate based application code deals with following interfaces provided by the Hibernate Core
Collection Interfaces
Collection Interfaces     ... of several interfaces, and classes that implement those interfaces, contained within... of objects.  Different interfaces describe different types of functionalities
EJB Interfaces
EJB Interfaces       Interface... interfaces. These are as follows 1)Remote interface:- Remote interface...; } 4)Localhome Interface:-The local interfaces extend the following interfaces
Interfaces and Abstract Classes - Development process
Interfaces and Abstract Classes  What are the Scenarios where we use Interface and Abstract Classes?  Hi Friend, Interface: Java does... by using the interface. Interfaces are useful when you do not want classes
Jep's Rich User Interfaces blog
Jep's Rich User Interfaces blog       About AJAX Performance and some other things by Jep Castelein of Backbase Read full Description
Classes and Interfaces of the I/O Streams
Classes and Interfaces of the I/O Streams   ...;Writer It uses for writing to character stream. Interfaces: The following summary of Interfaces provided by the java.io package shown in the table
Getting list of Local Interfaces on a machine
Getting list of Local Interfaces on a machine... to find out the total no of list of local interfaces available on a machine. Here... the local interfaces which are instances of NetworkInterface class and displays
EJB 3.1 - EJB Interfaces are Optional
In EJB 3.1, now you do not need to define any interfaces for Session Beans, just like JPA Entities and Message Driven Beans. All you have to do is annotate a POJO with the @Stateless or @Stateful to get a fully functional EJB
What are the different types of interfaces in java? - Java Interview Questions
What are the different types of interfaces in java?  Hi, Is it correct question.I faced this in one interview. If yes can u tell me please. thanks chandu
Overview of Networking through JAVA,Getting list of Local Interfaces on a machine
Getting list of Local Interfaces on a machine... to find out the total no of list of local interfaces available on a machine. Here... the local interfaces which are instances of NetworkInterface class and displays
Identify the interfaces and methods a JMS message-driven bean must implement.
Identify the interfaces and methods a JMS message-driven bean must implement.Prev Chapter 10. Message-Driven Bean Component Contract Next    Identify the interfaces and methods a JMS
Identify the interfaces and methods a CMP entity bean must and must not implement.
Identify the interfaces and methods a CMP entity bean must and must not implement.Prev Chapter 6. Component Contract for Container... the interfaces and methods a CMP entity bean must and must not implement. 
Identify correct and incorrect statements or examples about the client view of a session bean's local and remote component interfaces.
Identify correct and incorrect statements or examples about the client view of a session bean's local and remote component interfaces... the client view of a session bean's local and remote component interfaces
Java: Interfaces
Java: Interfaces An interface is a list of methods that must be defined... does, but abstract classes do allow static method definitions, and interfaces... different interfaces. If a class doesn't define all methods of the interfaces
Getting the implemented Interfaces
Getting the implemented Interfaces       In this section you will learn how to retrieve an Interface... retrieve Interfaces (included in the program) and store their references
Graphical User Interfaces
Graphical User Interfaces       A class library is provided by the Java programming language which is known as Abstract Window Toolkit (AWT). The Abstract Window Toolkit
Collections Overview
Java NotesCollections Overview Summary of Collections interfaces Most of the methods in the data structure classes are those of the interfaces... classes and interfaces, are in the java.util package. Indentation shows the class
JLabel font and color
component in your Swing application.   The most user-friendly interfaces
Java API
Java API       Java API Java API is not but a set of classes and interfaces that comes with the JDK. Java API is actually a huge collection of library
Hibernate API
on the persistent objects or the entity classes. The important classes and interfaces
Collection Interface
Java NotesCollection Interface The Collection interface is the parent of the List and Set interfaces, but not Map. Assume the following declaration for identifiers in the table below: Collection coll; boolean b; Object obj; int i
Collection Interface
Java NotesCollection Interface The Collection interface is the parent of the List and Set interfaces, but not Map. Assume the following declaration for identifiers in the table below: Collection coll; boolean b; Object obj; int i
FileFilter
. There are several file filtering classes and interfaces in Java, which often
What is AWT in java
interfaces and classes as follows: Interfaces and Descriptions
Interface in Java
; In this section we will learn about Interface and Marker Interfaces in Java... in an interface are "public and abstract" by default. Since interfaces... of an interface the keyword "implements" is used. Interfaces
Adapter Pattern
; This pattern establishes a relationship between the two unrelated interfaces... the interfaces such as WindowAdapter, KeyAdapter, MouseAdapter...-be-changed client, then an adapter is used so that both the interfaces work
Struts HTML Tags
Struts HTML Tags       Struts provides HTML tag library for easy creation of user interfaces... for the development of user interfaces. To use the Struts HTML Tags we have
JFormDesigner
JFormDesigner         JFormDesigner is an innovative GUI designer for Java? Swing user interfaces. Its outstanding support for JGoodies FormLayout
Introduction to Collections Framework
Framework provides a well-designed set of interfaces and classes for storing... implementation of interfaces and algorithms. Basically it is a unified architecture that consists the following collections:   Interfaces
Introduction to collection Implementations
-designed set of interfaces and classes used for storing and manipulating groups... for increasing performance.  It includes implementations of interfaces... the collection interfaces.  Implementations are also responsible for documenting
WindowTester Pro
interfaces. Spend less time and money testing Java GUIs Developers can focus... and consistent graphical user interfaces. Realize value over application lifespan
Visual WebGui
Visual WebGui       Visual WebGui is an open source rapid application development framework for graphic user interfaces of IT web applications. Visual WebGui lets you cut down
 

 

 

DMCA.com