Java Interview Questions & Answers part 1

Q: – Can I call a abstract method from a non abstract method ?

Yes, We can call a abstract method from a Non abstract method in a Java abstract class

Q: – How to Set the java path in Windows Operating system ?

Assuming you have installed Java in c:\Program Files\java\jdk directory:

  • Right-click on 'My Computer' and select 'Properties'.
  • Click on the 'Environment variables' button under the 'Advanced' tab.

Now alter the 'Path' variable so that it also contains the path to the Java executable. Example, if the path is currently set to 'C:\WINDOWS\SYSTEM32', then change your path to read 'C:\WINDOWS\ SYSTEM32;c:\Program Files\java\jdk\bin'

Q: – What are the Java popular editors  ?

Some of the popular java editors are given below  :

  • Notepad : On Windows machine you can use any simple text editor like Notepad (Recommended for this tutorial)
  • Netbeans : is a Java IDE that is open source and free which can be downloaded from
  • Eclipse : is also a java IDE developed by the eclipse open source community and can be downloaded from

Q: – What is a collection ?

Collection is a group of objects. java.util package provides important types of collections. There are two fundamental types of collections they are Collection and Map. Collection types hold a group of objects, Eg. Lists and Sets where as Map types hold group of objects as key, value pairs Eg. HashMap and Hashtable.

Q: – What is Java and list some features of Java ?

Java is a high-level programming language originally developed by Sun Microsystems and released in 1995. Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.

  • Java Programming Language is simplified to eliminate language features that cause common programming errors. Java source code files are compiled into a format called bytecode, which can then be executed by a Java interpreter.
  • Java is an object-oriented language, and this is very similar to C++. In java everything is an Object. Java can be easily extended since it is based on the Object model.
  • Java is Robust :Java makes an effort to eliminate error prone situations by emphasizing mainly on compile time error checking and runtime checking.
  • Multi-threaded : With Java's multi-threaded feature it is possible to write programs that can do many tasks simultaneously. This design feature allows developers to construct smoothly running interactive applications.

Q: –What are the components of Java Platform ?

Java platform has two components:

  • The Java Virtual Machine
  • The Java Application Programming Interface (API)

The Java Virtual Machine is the root for the Java platform and is integrated into various hardware-based platforms.The API is a large collection of ready-made software components that provide many useful capabilities. It is grouped into libraries of related classes and interfaces; these libraries are known as packages.

Q: – Why Java is called Platform independent ?

Java is platform independent. Because the Java VM is available on many different operating systems, the same .class files are capable of running on Microsoft Windows, the Solaris™ Operating System (Solaris OS), Linux, or Mac OS.

Q: – What is the solution if you get “javac: Command not found” ?

If you receive this error, UNIX cannot find the compiler, javac. Here's one way to tell UNIX
where to find javac. Suppose you installed the JDK in /usr/local/jdk1.7.0. At the prompt you
would type the following command and press Return:


Note: If you choose this option, each time you compile or run a program, you'll have to precede your javac and java
commands with /usr/local/jdk1.7.0/.

To avoid this extra typing, you could add this information to your PATH variable. The steps for doing
so will vary depending on which shell you are currently running.

Q: – What methods java providing for Thread communications ?

Java provides three methods that threads can use to communicate with each other: wait, notify, and notifyAll. These methods are defined for all Objects (not just Threads). The idea is that a method called by a thread may need to wait for some condition to be satisfied by another thread; in that case, it can call the wait method, which causes its thread to wait until another thread calls notify or notify All.

Submitted By:-Ankur Jain           Email-ID: –