Saturday, 28 April 2018

Java Interview Question for Experienced Candidates:


1)What are the Java 8 Features in java?

      *For Each() method in Iterable Interface.
      *Default and Static methods in interface.
      *Functional Interface and Lambada Expression.
      *Collection API Improvements.

 NOTE: We can use default and static keyword to create Interface with Implementation.

2)Define a Concrete Class?

    *used for Specific Requirement.
    *Object of Concrete Class can be created directly
   *Containing fully defined methods or implementation methods.

3)Steps for remove duplicates elements in java?

    public class RemoveDuplicates
       
           {
                ArrayList<object> a1= new ArrayList<object>();
                al.add("JAVA"); //you can add any number of the data you want
             
                     System.out.println("the elements are:" +a1);
                   
                       for(int i=0; i<a1.size(); i++)
                             {
                                  if(a1.get(i).equals(a1.get(j)))
                                    {
                                        a1.remove(j);
                                        j--;
                                     } 
                                 }
                         }
           System.out.println("After Removing the duplicates elements:" +a1 );

      }
}


4) Define halt() function?
         public void halt(int staus):
                           Forcibly terminates the currrently running JVM.
                           This method never returns normally.
                         
5) exit() function;
            public void exit(int status):
                           This method terminates the currently running Java Virtual Machine.
                     java.lang.sysyem.exit();
             
















No comments:

Post a Comment