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



Home Answers Viewqa Java-Interview-Questions Java and Collection Interfaces

Have Programming Question? Ask it here!
 
 
 


Kalaiselvi.M
Java and Collection Interfaces
1 Answer(s)      6 years and 6 months ago
Posted in : Java Interview Questions


I wanted to know more about Java and Collection Interfaces


Advertisement
View Answers

February 27, 2008 at 4:06 PM


Java and Collection Interfaces

Interface : Types of Interfaces

Interface ,simply say something to a media by using another media. For example TV Remote is an interface because it is medium for giving the command to a TV for changing the channels or to ON/OFF the TV.

Interface is nothing , the collection of methods with empty implementations and constants variables .All the variables declarations are static and final. All the methods in an interface are "public and abstract" by default. Interfaces are abstract in nature so they can not be directly instantiated.For defining the methods of an interface use the keyword "Implements ".Interfaces are just like the abstract classes but the major difference between these two is that interface contains all the methods abstract while abstract classes must have at least one abstract method.

Interface Definition

access specifier interface(keyword) interfacename{

constant variable declarations ;

abstract methods declarations ;

}

For Example

interface Firstinterface // use keyword interface & interfacename
{
int a=100; // by default contant variable

}
interface Secondinterface extends Firstinterface // for accessing the functionality of Firstinterface use extends keyword
{
int b=200;
int sum = a+b;
void Display();
}
class Interfaceclass implements Secondinterface // for using the functionality of Firstinterface & Secondinterface use the keyword implements
{
public void Display()
{
System.out.println(sum);
}
public static void main(String[] args)
{
Interfaceclass temp = new Interfaceclass();

temp.Display();
}
}

In Java there is no types of the interfaces . In collection we have three interfaces such as :-

(1) List interface

(2) Set interface

(3) HashMap interface


Neetu ;)


Related Tutorials/Questions & Answers:
Collection Interfaces
Collection Interfaces     .... The following diagrams shows the framework of core collection interfaces hierarchy. Table of the ordered and unordered Collection interfaces shown
Java interfaces
Java interfaces  What interface must an object implement before it can be written to a stream as an object
Advertisements
java interfaces
java interfaces  sample code for multiple interface   interface A { void test(int i); } interface B { void test(String s); } public class MultipleInterface implements A, B { public void test(int i
Marker interfaces in java
Marker interfaces in java  how marker interfaces work
Java Collection
Java Collection  What is the Collection interface
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
interfaces - Java Beginners
, super class constructor runs.what about interfaces?  Hi Friend... is called the base class or the parent class. To derive a class in java the keyword... to : http://www.roseindia.net/java/language/inheritance.shtml Thanks
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
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
Java collection
Java collection  What are differences between Enumeration, ArrayList, Hashtable and Collections and Collection
interfaces - Java Beginners
interfaces  examples on interfaces  Hi Friend, Please visit the following links: http://www.roseindia.net/java/master-java/interface.shtml http://www.roseindia.net/java/java-exception/create-interface.shtml
Collection in java
Collection in java  What are the meaning of the letters E,T,K and V that come in the collection concept
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
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
Java collection
Java collection  What is relation between map and set
Java Collection
Java Collection  What are Vector, Hashtable, LinkedList and Enumeration
Java collection
Java collection  What are differences between Enumeration, ArrayList, Hashtable and Collections
java collection
java collection  how do I use a treeset to print unique words
Java Collection API - Java Tutorials
Java Collection API Collection was added to Java with J2SE 1.2 release... of the collection interfaces. Also, they are reusable data structures. Algorithms... and sorting, on objects that implement collection interfaces. The same method can
Java garbage collection
Java garbage collection  What is Garbage Collection and how to call it explicitly
Custom Collection Implementations
the Java  built-in Collection Interfaces implementations. Apart from these, some times programmer need to implement their own collections classes.  The Java... Custom Collection Implementations  
Collection classes in java
is the reason using java collection classes saved/stored the data/content.I don't understand, what is the idea using java collection classes in project. Or the data is stored in both database and java collection classes
Collection classes in java
is the reason using java collection classes saved/stored the data/content.I don't understand, what is the idea using java collection classes in project. Or the data is stored in both database and java collection classes
Java collection -Hashtable
Java collection -Hashtable   What is Hashtable in java collection?   Java collection -Hashtable;- The hashtable is used to store value in the form of map key with value. import java.util.Hashtable; import
Java collection-LinkedList
Java collection-LinkedList  How to use java collection-linked list ?   Example: import java.util.Iterator; import java.util.LinkedList; import java.util.List; public class LinkedListExample{ public static void
garbage collection - Java Beginners
of memory.It identifies the objects that are no longer used by a program. A Java object is subject to garbage collection when it becomes unreachable to the program..."algorithms.Instead of "destructor" in c++ , java supports garbage collector
Java collection Queue Example
Java collection Queue Example  How can we use Queue in java collection?   import java.util.LinkedList; import java.util.Queue; public... LinkedList(); queue.add("Java"); queue.add("DotNet
garbage collection implementation dependent java
garbage collection implementation dependent java  How a garbage collection works in Java
Collection Framework - Java Beginners
Collection Framework  Pls explain the disadvantages of using collection framework as it was written in this forum ? It must cast to correct type. ? Cannot do compile time checking. I couldnot get in detail as to what
Java collection LinkedHashSet
Java collection LinkedHashSet  How can we use LinkedHashSet in java collection?   import java.util.Iterator; import java.util.LinkedHashSet; import java.util.Set; public class LinkedHashSetExample{ public static
Java Collection-TreeSet
Java Collection-TreeSet  What is TreeSet in Java Collection?   Example: import java.util.Iterator; import java.util.TreeSet; public class TreeSetExample{ public static void main(String [] args
Java collection Stack example
Java collection Stack example  How to use Stack class in java collection?   The Stack class uses the First In Last Out(FILO) mechanism... :- -1 Description:- The above example demonstrates you the Stack class in java
Java collection HashSet
Java collection HashSet  How can we use HashSet in java program?   The hashSet class is used to create a collection and store it in a hash table. Each collection refer to a unique value. import java.util.Collections
Java collection Vector
Java collection Vector  How can we use the vector class in java program?   The vector class is similar to the ArrayList class except that the vector class is synchronized. import java.util.Iterator; import
java collection - Development process
java collection - creating and comparing lists using Java  How to compare two list in java? and i have to create two more list from old two list. Comparing and Creating new list in Java Java Example code for creating
java collection - Java Beginners
java collection  want a java program using collections for an algorithm the algorithm is give below algorithm has some transactions T1=ABCE T2=CDE T3=DE T4=CDEG T5=BG T6=AE T7=BCG T8=C T9=A now compare T9
Java HashSet Collection problem
Java HashSet Collection problem  Here's how the HashSet works. It maintains an array of buckets. When an object is inserted, it finds the appropriate bucket corresponding to the objects HashCode. Then it calls the equals method
collection
collection  As we know array holds the similar kind of elements, then in collection how toArray() method will convert the collection having different objects as elements to an array in java
Java collection HashSet and TreeSet
Java collection HashSet and TreeSet   How can we used HashSet and TreeSet in the both Example?   import java.util.HashSet; import java.util.Set; import java.util.TreeSet; public class SetsExample{ public static
What is garbage collection? - Java Beginners
. How garbage collection works in java? Thanks   Garbage Collection in Java In Java when program executes the JVM creates the object... in Java. Check the garbage collection code at http://www.roseindia.net/answers
Java garbage collection
Java garbage collection  Can an unreachable object become reachable again
Java garbage collection
Java garbage collection  Can an object be garbage collected while it is still reachable
Java garbage collection
Java garbage collection  How many times may an object's finalize() method be invoked by the garbage collector
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
Java Collection iterator with example
The Java Collection Iterator is present at the highest level interface in the Collection framework. Iterator interface has methods for traversing.... Example of Java Collection Iterator import java.util.ArrayList; import
Collection
Collection  What is the exact difference between lagacy classes and collection classes? and Enumeration is possible on Collection classes
collection
, Hashtable and Collections and Collection?   Enumeration : It is series... : It is re-sizable array implementation. Belongs to 'List' group in collection... Map in collection. Collections : It implements Polymorphic algorithms which
Java Garbage Collection
Java Garbage Collection       The Java language is the most widely used programming language to rely on garbage collection. The name "garbage collection" implies
 

 

 

DMCA.com