Basic core java interview questions and answers for freshers

  Part 3

Basic core java interview questions and answers for freshers covered in this post:


    Basic core java interview questions and answers for freshers


        What is the difference between sleep() and wait() in java?

     

    Sleep()

    Wait()

    1.

    The sleep () method can be used to pause the process for some time or the time we want to.

    Wait() is a method that can be used to put the thread in a waiting state.

    2.

    Sleep() method never release the lock while sleeping the thread.

    Wait() method can release the lock while a thread is waiting.

    3.

    Syntax:

     

    synchronized(LOCK) {

       Thread.sleep(1000);

    }

    Syntax:

     

    synchronized(LOCK) {

      LOCK.wait();

    }



        What is the difference between notify and notifyAll()?

    -    Notify() method can be used to notify only one thread at a time which is waiting in a waiting state.

    -  NotifyAll() method can be used to notify all threads at a time that is waiting in a waiting state.


     

    Click here to Purchase on AmazonClick here to Purchase on Amazon

    Click here to Purchase on Amazon

    Note: Please click on Image to Purchase the books from Amazon.in

        What are the Implementation classes of List Interface?

    -          List interface is the child interface of the Collection interface.

    -          List of implementation classes of List interface.

    1.        ArrayList.

    2.       LinkedList.

    3.       Vector.

    §  Stack.


        What are the implementation classes of Set Interface?

    -          Following are the Classes which implements Set interface.

    1.       HashSet.

    2.       LinkedHashSet.

    3.       TreeSet.


        What is the difference between Array and ArrayList?

     

    Array

    ArrayList

    1.

    An array is a fixed length of data structure. It's not dynamic.

    ArrayList is not a fixed type of data structure Arraylist is dynamic.

    2.

    An array can store only homogeneous objects.

    ArrayList can store homogeneous as well as heterogeneous objects.

    3.

    While declaring an array it is mandatory to declare the size of an array.

    While declaring an ArrayList it is not mandatory to declare the size of ArrayList.

    4.

    You cannot add a new element once the array gets full.

    You can easily add a new element once the ArrayList gets full.

    5.

    An array is not a part of the collection framework.

    ArrayList is a part of the Collection framework.

    6.

    An array can be single or multidimensional.

    ArrayList cannot be multidimensional.

    7.

    For iterating array, we can use while loop, for loop, for each loop.

    For iterating ArrayList, we can use an iterator.

    8.

    Arrays are by default type-safe.

    ArrayList is not by-default type-safe. We have to make it type-safe explicitly.

    9.

    Performance of array is best than ArrayList.

    The performance of ArrayList is a little low as compared to an array.



        What is the difference between Stack and Queue?

     

    Stack

    Queue

    1.

    The stack data structure is based on LIFO (Last In First Out) principle.

    The queue data structure is based on FIFO (First In First Out) principle.

    2.

    Stack has only one pointer points to elements which is always point on top.

    The queue has two pointers, Front Pointer which is pointing to the first element and the rear pointer points to the last element.

    3.

    Insertion operation is called Push.

    Insertion operation is called Enqueue.

    4.

    The deletion operation is called Pop.

    The deletion operation is called Deque.

    5.

    Insertion and deletion in stacks take place only from one place called Top.

    Insertion operation takes place at the rear of the queue and deletion takes place at the front of the queue.



        What is bytecode?

    -          Java bytecode is the instruction set for the Java Virtual Machine.

    -          Bytecode is the intermediate representation of a Java program.


        What is the different between Linkers and Loaders?

     

    Linkers

    Loaders

    1.

    The main functionality of Linkers is to generate the executable file.

    The main functionality of Loaders is to load the executable files into the main memory.

    2.

    The process of combining source code to obtain executable code is called Linkers.

    The process of loading executable code to the main memory for further execution is called Loaders.

    3.

    The linker takes input from the Compiler or assembler.

    Loaders take input from Linkers.

    4.

    There are two types of Linker available.

    1.       Dynamic Linker.

    2.       Linkage Editor.

    There are four types of loader available.

    1.       BootStrap Loaders.

    2.       Absolute Loaders.

    3.       Direct Linking Loaders.

    4.       Relocating Loaders.



        What is Predicate functional interface?

    -          Predicate is used to perform a particular condition check.

    -       Predicate can be used like if condition. It will always return a Boolean value.

    -          Please refer to the below example.

    @FunctionalInterface

    public interface Predicate<T> { 

    }


        What is Function functional interface?

    -     Function interface takes one argument and returns any type of object. As we have seen Predicate return only Boolean but Function returns any type of object.

    -     Please refer to the below example for syntax.

    @FunctionalInterface

    public interface Function<T, R> { 

    }


    • Java interview questions and answers all MNC - Click here
    • Basic core java interview questions and answers for freshers - Click here
    • Core java interview questions for 3 years experience - Click here
    • Core java interview questions and answers for 3-5 years exp - Click here
    • Core java interview questions and Answers for 5 - 7 Years exp - Click here
    • Basic Java Interview Questions and Answers - Click here
    • Java interview questions and answers on oops - Click here
    • Java interview questions and answers on Strings - Click here
    • Java interview questions on exception handling - Click here
    • Interview questions on multithreading in java for experienced - Click here
    • Interview questions on serialization in java for experienced - Click here

    • Interview questions on inner class in java for experienced - Click here
    • Interview questions on Collections in java for experienced - Click here


    Upcoming questions in next post:

    31. What is the purpose of Arrays utility class.

    32. What is Stack and what are the characteristics of Stack.

    33. What are the characteristics of Hashset?

    34. What are the characteristics of Queue Interface.

    35. Which data structure has implemented LIFO strategy.

    36. Which data structure has implemented FIFO strategy.

    37. What is the difference between List and Set.

    38. What is loaders? What are the types of loaders available.

    39. Can I have multiple abstract methods in functional interface.

    40. Can you create your own functional interface.


    Previous Post                                                                    Next Post



    Thank you techies for visiting this blog. I hope you enjoyed this blog and got more technical knowledge. I have tried to cover all types of questions and provided examples tested on eclipse as much as I can. Guys, please don’t just mug up the questions and answers. Try to clear your concepts with examples. Try to write a code on eclipse once you read the concepts. It will help you to memorize the concepts for a very long time. Simultaneously you will be prepared for interview programs as well. It will help you to survive in the IT sector for a long time. It may be easy to crack an interview but it's really tough to survive in the IT industry with inadequate knowledge and skills. 

    I have collected all the questions from actual interviews attended by my friends, colleagues, college mate and classmate. I have covered frequently asked questions as well as challenging questions. I have included many programs to understand the concept thoroughly. I will try to explain the concept with the help of a real-time program in eclipse. 

    You can share more questions which are not covered in this blog or post. Always welcome your suggestions and queries. I will definitely try to resolve it. 

    Please comment your queries and new set of questions under the comment sections. I will create a new post for those questions. 

    My total experience is 10. Initially I had worked on some support projects and then I moved to java projects. I had worked with many multi-national companies like R-Systems, Tata Consultancy Services, Cybage Softwares.  Fortunately, TCS and Cybage has given me an opportunity to take interviews for experienced candidates. I have conducted more than 1000 interviews by now.

    Mock sessions will be conducted for minimal charges. I will guide you personally on how to crack interviews. All sessions will be online sessions only. My interview book will be provided free of cost if you enroll for personal training. Once you have done practice then I assured you will definitely crack almost all java interviews. 

    I have published my book named with "All MNC Java Interview" which is available on amazon. You can go through it or you can directly contact to me if you are interested to read the book. I will give you special discount. I have covered near about 550 questions and answers with program tested on eclipse and necessary diagram. 

    I have covered interview questions asked in all reputed MNC like TCS, Infosys, Capgemini, Tech Mahindra, Cognizant, City Bank, Barclays, Amdocs, Mindtree etc. My purpose behind this book is, help you to get a job in your dream company. I can understand this is a struggling period for job seekers and freshers. Everybody must have gone from this phase. so never give up. Keep upgrading yourself. I am sure you will get a job in your dream company. All the best!!! 

    Please reach out to me for personal training for interview preparation. 

    You can reach out to me at mncjavainterview@gmail.com.

     


    Post a Comment

    0 Comments