Java Basics - Interview Questions and Answers

Why Java Basics Interview Questions?

In this section you can learn and practice interview questions based on "Java Basics" and improve your skills in order to face the interview, competitive examination and various entrance tests (CAT, GATE, GRE, MAT, Bank Exam, Railway Exam etc.) with full confidence.

Where can I get Java Basics interview questions and answers with explanation?

IndiaBIX provides you lots of fully solved Java Basics interview questions and answers with Explanation. All students, freshers can download Java Basics quiz questions with answers as PDF files and eBooks. Solved examples with detailed answer description, explanation are given and it would be easy to understand. View the solution for the problems with feel and good user interface; easily go through all questions and answers.

How to answer Java Basics interview questions?

You can easily answer the interview questions based on Java Basics by practicing the exercises given below.

  1. What is the difference between a constructor and a method?

    A constructor is a member function of a class that is used to create objects of that class. It has the same name as the class itself, has no return type, and is invoked using the new operator.

    A method is an ordinary member function of a class. It has its own name, a return type (which may be void), and is invoked using the dot operator.

  2. What is the purpose of garbage collection in Java, and when is it used?

    The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources can be reclaimed and reused.

    A Java object is subject to garbage collection when it becomes unreachable to the program in which it is used.

  3. Describe synchronization in respect to multithreading.

    With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources.

    Without synchonization, it is possible for one thread to modify a shared variable while another thread is in the process of using or updating same shared variable. This usually leads to significant errors.

  4. What is an abstract class?

    Abstract class must be extended/subclassed (to be useful). It serves as a template. A class that is abstract may not be instantiated (ie. you may not call its constructor), abstract class may contain static data.

    Any class with an abstract method is automatically abstract itself, and must be declared as such. A class may be declared abstract even if it has no abstract methods. This prevents it from being instantiated.

  5. What is the difference between an Interface and an Abstract class?

    An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods are implicitly abstract.

    An interface has all public members and no implementation. An abstract class is a class which may have the usual flavors of class members (private, protected, etc.), but has some abstract methods.

  6. Explain different way of using thread?
    The thread could be implemented by using runnable interface or by inheriting from the Thread class. The former is more advantageous, 'cause when you are going for multiple inheritance, the only interface can help.

 [ Page 1 of 17  Jump... Next »

Jump to page : 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |