write your answers here
Wednesday, 31 August 2011
differents between string and string buffer? java interview questions ...
write your answers here
what is array list? java interview questions ...
write your ans here
what is map interface? java interview questions ...
write your answers here
what is exception? java interview questions ...
write your answers here....
what is list? java interview questions ...
write your answers here
what is thread? java interview questions ...
soon the answer uptade......
Tuesday, 30 August 2011
whai is set interface? java interview questions ...
Answer :
It has two useful concrete classes that implements sets
Example:
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;
public class SetExample {
public static void main(String[] args) {
// Set example with implement TreeSet
Set<String> s=new TreeSet<String>();
s.add("b");
s.add("a");
s.add("b");
Iterator it=s.iterator();
while(it.hasNext())
{
String value=(String)it.next();
System.out.println("Value :"+value);
}
}
}
Output
Set Value :a
Set Value :b
set ignore the duplicate value.
- Java collections Set interface is part of java.util package.
- A set is a public interface that extends the collection interface
- It holds unique values(set does not contain duplicate elements).
It has two useful concrete classes that implements sets
- java.util.HashSet
- Set value can get by Iterator interface.
Example:
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;
public class SetExample {
public static void main(String[] args) {
// Set example with implement TreeSet
Set<String> s=new TreeSet<String>();
s.add("b");
s.add("a");
s.add("b");
Iterator it=s.iterator();
while(it.hasNext())
{
String value=(String)it.next();
System.out.println("Value :"+value);
}
}
}
Output
Set Value :a
Set Value :b
set ignore the duplicate value.
Monday, 29 August 2011
what is an interface? java interview questions ...
Ans:
syntax:
interface interface name{
//declaration of methods and constants
}
class class name implements{
//implementation codes
}
- An interface is a named collection of method declarations and constant declarations.
- here we only declare the methods not a implementation.
- it's implemented by a class using implements keyword.
syntax:
interface interface name{
//declaration of methods and constants
}
class class name implements{
//implementation codes
}
Subscribe to:
Posts (Atom)

