bookmate game
Vibrant Publishers

CORE JAVA Interview Questions You'll Most Likely Be Asked

Notify me when the book’s added
To read this book, upload an EPUB or FB2 file to Bookmate. How do I upload a book?
  • Elvin Mahmudovhas quoted5 years ago
    8: How will you define Synchronization?

    Answer:

    Synchronization is a locking mechanism which is used to control the threads. For example, if multiple threads try to access a shared resource at the same time, then we need some way for the resource to be accessed by only one Thread at a time. So, the main purpose of Synchronization is to protect and secure data.
  • Elvin Mahmudovhas quoted5 years ago
    e can create threads in two ways as described below:

    a) By extending “Thread” class

    b) By implementing the interface called “Runnable”
  • Elvin Mahmudovhas quoted5 years ago
    hat is the difference between wait() and sleep()?

    Answer:

    The sleep(n) asks the thread to wait for a specific amount of time. The thread wakes up exactly after the specified amount of time. The wait(x) method keeps the thread waiting for maximum specified amount of time. It may be invoked by a notify() or notifyAll() method anytime before the specified time.
  • Elvin Mahmudovhas quoted5 years ago
    There are three types of exceptions we need to take care of. They are:

    a) Runtime Exception or Unchecked Exception: These type of exceptions occur during run time as we don’t write code to handle exceptions

    b) Checked Exception: These types of exceptions are handled using try, catch, finally, throw or throws keyword.

    c) Error: It is the behavior which stops the working of the system during program execution.
  • Elvin Mahmudovhas quoted5 years ago
    Garbage collection is an automatic feature which takes care of memory management in Java.

    Whenever the objects are declared null or if the objects are no longer used in a program, the Java Virtual machine clears those objects from memory and thereby make the system clean.
  • Elvin Mahmudovhas quoted5 years ago
    We need to understand three features while invoking overloaded methods. They are

    a) Widening: This feature always chooses the maximum range of bytes. For example, Long type holds maximum amount of bytes than Integer.

    b) Autoboxing: This feature converts the primitive to wrapper and vice versa.

    c) Var-args: Using this feature, we can pass multiple arguments to a method by passing single argument with three dots as shown below:

    public static String invokeFormat(String strPattern,Object... myArgs);

    As per the above order, Widening overcomes Autoboxing and Var-Args and Autoboxing overcomes Var-args.
  • Elvin Mahmudovhas quoted5 years ago
    Garbage Collection is done in the Heap Memory.
  • Elvin Mahmudovhas quoted5 years ago
    “default” it gets executed and executes the next statement as well.
fb2epub
Drag & drop your files (not more than 5 at once)