Java

JAVA OOPS INTERVIEW QUESTIONS AND ANSWERS

    Q.1. What  is  OOPS  in  Java?   Ans:  OOPS(Object-Oriented Programming System)   in  Java  is  a  programming  paradigm  that  is  based  on  the  concept  of  objects   which  contains   data(fields)  and  behavior(methods) .   Java  uses  OOPS  concept  to  represent  the  real  world  entities  by making  code  reusable,modular  and  much  easier  to  maintain.    The  basic 

JAVA OOPS INTERVIEW QUESTIONS AND ANSWERS Read More »

JAVA ARRAY INTERVIEW QUESTIONS AND ANSWERS

    Theoretical  Java Array Questions and Answers     1.Q. What is an Array in Java?   Ans:   An  Array  in  Java  is  a   container  object   which  is  dynamically   allocated   that  holds  a  fixed  number  of  values  of  a  single  data  type  in  contiguous  memory  locations.  Array  allows  you  to  store  multiple elements   either

JAVA ARRAY INTERVIEW QUESTIONS AND ANSWERS Read More »

JAVA PROGRAM TO FIND THE MAXIMUM AND MINIMUM ELEMENT IN AN ARRAY

    An  array  of  integers  arr[]  , find  the  maximum  and   minimum   elements  in  the  array.   Examples:   Input :  arr[] =[5,9,15,3,65,35];   Output :   [3 , 65 ]   Explanation :  The  minimum  element  is  3  and  the  maximum  element  is  65.       The  best  approach  to  find  the  maximum 

JAVA PROGRAM TO FIND THE MAXIMUM AND MINIMUM ELEMENT IN AN ARRAY Read More »

JAVA PROGRAM TO COUNT THE OCCURENCES OF EACH ELEMENT IN AN ARRAY

  To  count   the  number  of  occurence  of  each  elements  in  java, using  HashMap  is  the  most  efficient  and  standard   approach, which  runs  on  O(n)   time  complexity.       Example :     import  java.util.HashMap; import  java.util.Arrays; public  class   ElementCounter{ //Method  to  count  the   occurence  of  each  elements  in  array        

JAVA PROGRAM TO COUNT THE OCCURENCES OF EACH ELEMENT IN AN ARRAY Read More »

JAVA PROGRAM TO REMOVE DUPLICATE ELEMENTS FROM THE ARRAY

    There  are  many  approaches  to  remove  duplicate  elements  from  the  array. The  one  of  the  easiest  way  to  remove  duplicate  elements  from  the  array  is    using  HashSet,  which  automatically   remove  duplicate  elements.         Example :      import    java.util.*; public  class   RemoveDuplicates{  //Function  to  remove  duplicate elements  from   array

JAVA PROGRAM TO REMOVE DUPLICATE ELEMENTS FROM THE ARRAY Read More »

JAVA ARRAY CODING AND PROGRAMMING INTERVIEW QUESTIONS AND ANSWERS

        Write  a  Java  Program  to  Reverse  an  Array   Write  a  Java  Program   to  remove   duplicate  elements  from  the  Array   Write  a  Java  Program  to  count  the  occurence  of  each  element  in  an  Array   Write  a  Java  Program   to  find  the  second  largest  element  in   the  Array   Java 

JAVA ARRAY CODING AND PROGRAMMING INTERVIEW QUESTIONS AND ANSWERS Read More »

JAVA PROGRAM TO REVERSE THE WORDS OF A STRING

  In  this   approach   we  are  using  split()  method  to  reverse  the  words  of  a  string.       import  java.util.*;   public  class   ReverseWords {         public  static  void  main(String  args[] ) {         Scanner  sc=new   Scanner(System.in);         System.out.println(“Enter  a  String”);        

JAVA PROGRAM TO REVERSE THE WORDS OF A STRING Read More »