Top Java Interview Questions and Answers in 2021

Java has become an eternal contributor to the software development domain. Not only need to learn and master Javanese skills but also to practice this skill in real-time. In this article, we take you, some of the most sought-after interview Java interview questions that will help you take a big interview process and help test your skills and knowledge on the absolute. You can access various programming and technical courses on the Great Learning Academy and get your free certificate.

1. What is Java?

Java is a general-based general-purpose programming language, object oriented and very popular. This is one of the most popular programming languages ​​in the world.

Hello World in Java:

public class file names {

Public Static Void Utama (Args String []) {

System.out.println (“Hello World!”);



2. How do I install Java?

Install Java through the command prompt so that it can produce the log file needed to solve the problem.

Go to and click the download button Java free.

Click the Save button and save Java software on the desktop

Verify that Java software is stored on the desktop.

Open the Windows Command prompt window.

Windows XP: Click Start -> Run -> Type: cmd

Windows Vista and Windows 7: Click Start -> Type: CMD in the field Start Search.

CD <java download directory> (eg download or desktop etc.)

Irun Installer and follow the instructions on the screen.

3. How do I reverse the string in Java?

“String str =” “Hello” “;

Reverse string (string str) {

  StringBuilder SB = New StringBuilder ();

  SB.Append (STR);

  1. Verse ();

  Return SB.Tostring ();

} “

  1. What is the Utas in Java?

Thread allows the program to operate more efficiently by doing a number of things at the same time.

Utas can be used to carry out complicated tasks in the background without disturbing the main program.

It can be made by expanding the UTAS class and overriding the Run () method:

Extend the syntax

Public class MyClass extends Ustas {

Public Void Run () {{

System.out.println (“This code runs in utas”);



5. How do you take input on Java?

“Scanner in = New Scanner (;

      System.out.print (“” Please enter 1: “”);

      int hour1 = in.nextint ();

      System.out.print (“” Please enter 2: “”);

      int hour2 = in.nextint ();

      System.out.print (“” Please enter 1st minute: “”);

      int min1 = in.nextint ();

      System.out.print (“” Please enter 2 minutes: “);

      int min2 = in.nextint (); “

6. How do you set the path in Java?

Windows 10 and Windows 8

In search, search and then select: system (control panel)

Click the Advanced System Settings link.

Click the environment variable. In the system variable parts, find the path environment variable and select. Click Edit. If the path environment variable does not exist, click New.

In the edit window system variables (or new system variables), specify the value of the path environment variable. Click OK. Close all the remaining windows by clicking OK.

Reopen the command prompt window, and run your java code.

Mac OS X.

To run a different Java version, both specify the full path or use the java_home tool:

% / usr / libexec / java_home -v 1.8.0_73 -exec Javac -Version

Solaris and Linux

To find out whether the path is set correctly:

In the terminal window, enter:

% Java -Version.

This will print the Java tool version, if you can find it. If the version is old or you get a java error: Command is not found, then the path is not set correctly.

Determine which java executable is first found on your path

In the terminal window, enter:

Which% Java%

7. What is enumeration in Java?

Enumeration means a list of constants named. In Java, enumeration defines class types. Enumeration can have constructor variables, methods and instant. It was made using Enum keywords. Each enumeration constants are public, static and final by default. Although the enumeration defines the type of class and has a constructor, you do not instantiate enum using a new one. The enumeration variable is used and stated in the same way as you do primitive variables.

Java is a general-based general-purpose programming language, object oriented and very popular. This is one of the most popular programming languages ​​in the world. Join the Java certification course today and become certified.

8. What is inheritance in Java?

The process by which one class acquires property (data member) and other class functionality (method) is called inheritance. The legacy purpose is to provide the ability to return code so that a class must write only the unique features and the remaining general properties and functions can be extended from other classes.

Children’s class:

Classes that expand other class features are known as children’s class, sub-class or derivative classes.

Parent class:

Classes that are nature and functionality are used (inherited) by other classes known as the parent class, super class or base class.

9. How do you compare two strings on Java?

“// Both have the same value

New string (“” test “). Same with (“” test “) // -> right

// … but they are not the same object

New string (“” test “) ==” “test” “// -> false

// … this is also not

New string (“” test “) == new string (” “test”) // -> false

// … but this is because literals are intermedenced by

// compiler and thus refer to the same object

“” Test “” == “” test “” // -> right “

10. What is abstraction in Java?

Objects are object-oriented building blocks. The object contains several properties and methods. We can hide it from the outside world through access modifiers. We can provide access only for functions and properties needed to other programs. This is a common procedure for implementing abstraction on oops.

Related Articles

Leave a Reply

Back to top button