Commonly Asked Java Programming Interview Questions

By Commonly Asked Java Programming Interview Questions

In Coding Interview Preparation Ultimate Guide article, I explained in details everything you need to prepare yourself for coding interviews. Now let's see some of the popular interview questions with answers for both beginners and experts. These interview questions have been designed with a purpose of getting you prepared for interview questions you may encounter. These are only Java Programming language interview questions. Based on my experience, interviewers start by asking some basic interview questions and then progress to more advanced ones based on what you answer.

Now let's quickly see a list of interview questions and answers.

1. What do you know about Java?

Java is the high-level, object-oriented, robust, secure programming language, platform-independent, high performance, Multithreaded, and portable programming language. It was developed by James Gosling in June 1991. It can also be known as the platform as it provides its own JRE and API.

2. List any five features of Java?

Some features include:

  • Object Oriented
  • Platform Independent
  • Robust
  • Interpreted
  • Multi-threaded
  • Dynamic
  • Secure

3. What is the difference between JDK, JRE, and JVM?

JVM

JVM is an acronym for Java Virtual Machine; it is an abstract machine which provides the runtime environment in which Java bytecode can be executed. It is a specification which specifies the working of Java Virtual Machine. Its implementation has been provided by Oracle and other companies. Its implementation is known as JRE.

JVMs are available for many hardware and software platforms (so JVM is platform dependent). It is a runtime instance which is created when we run the Java class. There are three notions of the JVM: specification, implementation, and instance.

JRE

JRE stands for Java Runtime Environment. It is the implementation of JVM. The Java Runtime Environment is a set of software tools which are used for developing Java applications. It is used to provide the runtime environment. It is the implementation of JVM. It physically exists. It contains a set of libraries + other files that JVM uses at runtime.

JDK

JDK is an acronym for Java Development Kit. It is a software development environment which is used to develop Java applications and applets. It physically exists. It contains JRE + development tools. JDK is an implementation of any one of the below given Java Platforms released by Oracle Corporation:

  • Standard Edition Java Platform
  • Enterprise Edition Java Platform
  • Micro Edition Java Platform

More details here

4. What do you mean by Object?

The Object is the real-time entity having some state and behavior. In Java, Object is an instance of the class having the instance variables as the state of the object and the methods as the behavior of the object. The object of a class can be created by using the new keyword.

5. What is a class?

A class is a blue print from which individual objects are created. A class can contain fields and methods to describe the behavior of an object.

6. What kind of variables a class can consist of?

  1. Local Variable - Variables defined inside methods, constructors or blocks are called local variables. The variable will be declared and initialized within the method and it will be destroyed when the method has completed.
  2. Instance Variable - Instance variables are variables within a class but outside any method. These variables are instantiated when the class is loaded.

7. What is the constructor?

Constructor gets invoked when a new object is created. Every class has a constructor. If we do not explicitly write a constructor for a class the java compiler builds a default constructor for that class.

8. What is an Exception?

An exception is a problem that arises during the execution of a program. Exceptions are caught by handlers positioned along the thread's method invocation stack.

9. What is the difference between the final method and abstract method?

The main difference between the final method and abstract method is that the abstract method cannot be final as we need to override them in the subclass to give its definition.

10. Differences between HashMap and HashTable in Java.

  1. HashMap is non synchronized. It is not-thread safe and can’t be shared between many threads without proper synchronization code whereas Hashtable is synchronized. It is thread-safe and can be shared with many threads.
  2. HashMap allows one null key and multiple null values whereas Hashtable doesn’t allow any null key or value.
  3. HashMap is generally preferred over HashTable if thread synchronization is not needed

Are You Beginning Your Programming Career?

We have a vast of answers gathered from experts to help you. We offer:
  • Ready answers
  • Customers orders
And much more...
Visit www.answerswave.com now.

Conclusion

Good luck in programming. Everything is possible with dedication and determination. Just feel confident during your interview.

After the interview wait for result and be prepared for any outcome. If get hired proceed well with your job. If you got reject don’t lose hope. Move on and hope you something better. Keep learning and improving yourself and try again when ready.

We wish you best luck to have a good interviewer and all the very best for your future endeavor. Happy coding:-)

Was this article helpful?
Donate with PayPal: https://www.paypal.com/donate

Bessy
Eric Murithi Muchenah

Life is beautiful, time is precious. Make the most out of it.