In this Article, we are going to see Java Interview questions which you can find useful in telephonic or face-to-face developer interviews.

  1. What is the difference between Java Object and Java Application?

Java object is an object that will create at the time of execution. Java object is available at the time execution of the application. Java application means java program and this java program interpreted by JVM (Java Virtual Machine).

  1. What is the difference between multitasking and multithreading?

Multitasking: Multitasking is the activity to perform more than one task at a time on one computer.

Multitasking has two types:

Pre-emptive Multitasking- The running process is pre-empted to another processor system goes to ideal process without asking the user. For example Linux, Window NT.

Non Pre-emptive Multitasking- Before giving control to another process the system asks the process for execution. For example Window 3.1 and Mac OS 9.

Multithreading: It is the program that extends the functionality of multitasking by dividing the program into the thread and then individual thread utilize some amount of CPU and memory for execution. Startups post freelance projects on Java on some well-known freelancing websites. 

  1. What is Java Platform Independence?

Java is platform independent, means Java programs are not dependent on any platform, architecture or opening system like Windows or Linux. Java is platform independent because it has Java virtual machine when Java program compiled they are converted to class files which are a collection of byte code and directly understandable by JVM. That’s why same Java program can run on any operating system only JVM can differ according to OS.

  1. What is mean by ClassLoader in Java?

Java compiler load java program into a .class file. It is a collection of bytes a code and the class load is responsible for loading that the class file from file system network or any other location. The class loader has three type 1. Bootstrap2. Extension3. System class loader

  1. Explain the difference between Java and CPP?
  • Java is platform independent where CPP is platform dependent.
  • Java does not support pointer concept where CPP support the pointer concept.
  • Java support purely objects oriented concept where CPP support procedural, functional object oriented and template programming.
  • Java has to call through an interface to access the Java library where CPP calls directly to the system libraries for the programme.
  1. What are loop concepts in Java?

If you want to perform some lines of code repeatedly that time you should use the concept of a loop. Loop is the concept used when you want to perform a repetitive task in the programme.

For Loop: For loop is used to perform a repetitive task to given number of times. For loops are used when programmer know how many no of time the statement is repeated.

While loop: In ‘while’ you need to execute certain loop statement until the condition is satisfied. It means checking of condition is first

Do While Loops: In doing while loop statement executed at least one irrespective of condition. Because in do while loop the condition is checked after execution of the block.

  1. What are Java packages and state its significance?

Java package is a collection of packages and interfaces which are bunch together as they are related to each other. The package helps the developer to modularize the code and group code for proper reuse. Once the code packages, then it is imported in class and uses it.

  1. State difference between an abstract class and Interface in Java?

The difference between abstract class and interface is that abstract class can have a member of any access specifiers that is public and private with or without concrete implementation.

While using interface, we need to specify declaration of the public static method with no concrete implementation. The class which implements an interface must implement all methods of an interface while class which inherits from abstract class doesn’t require implementation all method of its superclass.

  1. How is garbage collection done in Java?

If object just not any more then garbage collection take place and object destroyed automatically. System.gc() or Runtime.gc() method call in Java for automatic garbage collection.

  1. In Java can we declare the main method of our class as private?

In Java, we cannot declare the main method as private .if the main method declares as a private developer won’t get any compilation error, but it will give runtime error. Therefore in Java main method must be public static to run any application.

  1. Inside static method can we call the non-static method?

If you want to declare a non-static method inside the static method, you need to create an object of the class first. By using object reference, you can invoke the method.

  1. What happens in Java when an exception does not handle by Java?

In Java, an exception is handled by try and catch block. Sometimes if an exception is not handled by trying and catch blocks the program get aborted or stop and no statement executes after the statement which causes exceptional throwing.

  1. What is the advantage of using Inheritance?

The advantage of inheritance is to reusability of code using inheritance subclass to reuse the code of its superclass. Polymorphism is another advantageous which allows new functionality introduced without affecting the existing one. These basics are important for freelance web developers.

  1. Can we override static method of a class?

In Java, we cannot override the static method. A static method is not belonging to individual objects, but it belongs to the class and resolve at the time of compilation.  When we try to override a static method, we will not get compilation as well as a runtime-error.

  1. In Java, can a class have multiple constructors?

The class has multiple constructors in java with different parameters. That constructor used for object creation depends on the arguments passed while creating the objects.

  1. How is an Object serialised in Java?

The object is converted into byte stream by serialization in Java. An interface with the name serialisable gets implemented by the class. All interface serialized and all object of a class implementing serializable and their state saved in the byte stream.

  1. How we store an Object in java?

In Java, only object declaration does not create memory space, but object creation created memory space from the heap. If the object is destroyed using garbage collection method space is available in a heap to the new object.

These questions are provided as reference and you can search for similar questions on the internet as well as get the basics clarified along with latest trends.