50+ Core Java Interview Questions and Answers 2023

Here are 50 or more of the most common core Java interview questions and answers that will help you pass even the hardest interviews.

Table of Contents

1. What is the JVM?

JVM stands for Java Virtual Machine. It is what makes Java a portable language that can be used on any platform. JVM is called \”virtual\” because it is an abstract system that runs programmes that have been \”compiled\” in Java. The Java ByteCode File or.class file is run by the JVM.

2. Mark up for multiple sets of swings.

Here are the different types of Swings Packages:
1. javax.swing gives you a group of Java Language Components that don\’t take up much space.
2. The javax.swing.plaf package provides one interface and many abstract classes that can be used to change the way a programme looks and feels.
3. javax.swing.plaf.multi gives you User Interface Objects made for Multi Platform Look and Feel.
4. The javax.swing.event package gives you events that Swing components send out.
5. javax.swing.tree provides classes and interfaces for working with java.awt.swing.JTree.
6. The javax.swing.undo package helps Text Editor Applications with Undo and Redo.

3. Write down what\’s different about C++ and Java.

1. Java is a true object-oriented language, while C++ can work with both objects and procedures.
Operator Overloading is not possible in Java, but it is possible in C++.
3.There are Header Files in C++, but there aren\’t any in Java.
4. Java supports Multi-Threading, but C++ doesn\’t.
5. Pointers are not used in Java, but they are used in C++.
Multiple inheritance is not supported in Java, but it is in C++.

4. Add Versions of Java to the list.

1. Java Enterprise Edition (J2EE): Used to make server-side programmes like Java Servlets and Java Server Pages.
2. Java Micro Edition (J2ME): A programming language used to make apps for mobile devices like cell phones and tablets.
3. Write Client Side Applets or Standalone Applications with Java Standard Edition (J2SE).

5. What is the Object-Oriented Programming Approach?

Object-oriented programming is a method that lets you break up programmes into smaller pieces. It does this by creating separate memory areas for data and functions that can be used as models to make copies of modules when they are needed. With Object-Oriented Programming (OOP), a problem can be broken up into parts called \”objects,\” which are then used to build data and functions.

6. Tell me about Java\’s Vector Class.

A Generic Dynamic Array called a \”Vector\” can be made with the help of a Vector Class. This Vector Class makes it easy to store any number and type of objects. These Objects that are accessed by the vector Class don\’t have to have similar parts. Vectors are used to implement arrays. So, vectors can be used to store a list of objects, even if their sizes vary.

7. What is a jdb?

The Java Debugger is what it is. Jdb is a tool that helps you find Java bugs. It is a Java Class Debugger Tool for the Command Line. It lets you look at and fix problems with both local and remote Java Virtual Machines.

8. What is AppletViewer?

AppletViewer is a Java programme that lets you run Java Applets from the command line. It\’s part of the Java SDK. The Java applet viewer can be used to make Dynamic Applets and to view Java Applets.

9. What is Object?

An object is a group of related software states and behaviors that work together. Object is essentially a single instance of the Class it belongs to. So, Software Objects can be used to represent things in the real world.

10. What is a bequest?

In Java, inheritance is a way for one Object to take on the properties of another Object. Classes can now be defined in terms of other Classes that have already been defined. This means that new Classes can take on the properties of older Classes.

11. Write down the different kinds of Java errors.

These are the kinds of errors that can happen in Java:

Compile Time Errors

This is mostly made up of Syntax Errors that the Java Compiler shows at Compile Time.

Run Time Errors

This is mostly made up of Logical Errors that aren\’t caught by the Java Compiler and can cause the programme to end unexpectedly. It has errors like \”Divide by Zero\” and \”Opening a file that doesn\’t exist.\”

12. What is the Instance Of Operator?

This operator is used to refer to variables that belong to objects. It checks to see if the first operand is like the second. It looks like this:

instanceOf (Class or Interface Type) (Object Reference Variable)

13. Write down the kinds of constructors.

There are different kinds of Constructors, such as:

1. Default Constructor: This is a function Object() { [native code] } with no parameters. If you do not define a function Object() { [native code] } for a Class, a Default function Object() { [native code] } is made for you.

2. Parameterized Constructor: A Parameterized function Object() { [native code] } is a Constructor that can be called with parameters.

3. Overloading the function Object() { [native code] }: Java supports polymorphism, which means that a class can have two or more methods with the same name. This is called method overloading.

14. Talk about the static methods.

In Java, static methods are used to make Methods or Functions that exist even when there are no Instances of a Class. These methods don\’t use any instance variables of any object in the class where they are defined. Static methods can only get to data that is also static. They can only call Static Methods. They can\’t call any other methods. You can\’t use This or Super Keywords in a Static Method.

15. Tell me what this word means.

There are times when a Function needs to refer to an Object that it calls. This keyword makes it easy to talk about an Object within that method. This keyword can be used to point to an object of the same type as the current class.

16. What is jar?

Java Archive is what Jar stands for. It is a tool that can combine multiple files into a single jar file or make a jar file bigger. It\’s basically a zip file with more space.

17. Write down the types of inheritance.

Java lets you use the following types of inheritance:
1. A Single Bequest
2. Inheritance Based on Rank
3. Multi-Level Inheritance
4. Multiple Inheritance

18. What does awt mean in Java?

Abstract Window Toolkit is what AWT is short for. It\’s mostly made up of graphical user interface design widgets that can be moved around with Layout Manager. AWT is platform independent. It gives the user access to Components, Containers, and Layout Managers.

19. Tell me about Java\’s subclass function Object() { [native code] }.

A Subclass function Object() { [native code] } is used to set up the instance variables of both the Sub Class and the Super Class. A Sub Class can call the Constructor of its next-highest-level Super Class. So, the Sub Class calls the Constructor methods of the Super Class by using the Super keyword. This causes the relevant function Object() { [native code] } from the Super Class to be run based on the arguments passed to it.

20. What does Final Keyword do?

If a variable is declared as \”final,\” its value can\’t be changed later in the programme. No matter what the Scope of the variable is, Java lets you declare it to be final.
Final int variable = 15; A Black Final is a local Final variable that has been declared but not given a value.

21. Make a list of some common Java API packages that are built in.

These are the Java Packages that are most often used:
It has support for Threads, Strings, Exceptions, and a lot more.
Date, Hash Tables, Vectors, and other things are supported by java.util.
Java.io: Help for Classes with Input and Output.
Networking is supported by Java.net.
Applets can be made with the help of Java.applet.

22. What does polymorphism mean?

Polymorphism is used to make it possible for routines or methods to behave differently depending on the situation. An operator or a Function can be set up so that it acts differently depending on where it is. In C, we have the Asterisk *, which uses Polymorphism by default. It automatically works as a Multiply Operator, a Pointer Operator, or a De-Reference Operator.

23. Describe Java\’s InputStream Class.

A class called InputStream is used to read 8-bit bytes. It has a Super Class called InputStream and a number of Sub Classes that support methods related to input. It can read bytes, close streams, mark positions in streams, move forward in a stream, and do a lot more.

24. Tell me about Java\’s Final Classes.

A Class is said to be \”Final\” so that it can\’t be \”Sub Classed.\” So, it helps to stop inheritance from being used on that particular class. So, a Final Class is a class that can\’t be broken down into smaller classes. If you try to extend Classes from a Class that has been marked as \”final,\” a Compile Time Error will be generated.

25. What is javah?

javah is a tool that makes the Source Files and Header Files that are needed to use Native Methods. So, Native Source Codes use these Header files to point to the Instance variables of an Object.

26. What does Java\’s \”method overloading\” mean?

It is a way that polymorphism is used. A method is overloaded if it has the same name but a different number of arguments or, in some cases, a different type of data. Method overloading is when two methods in the same Class have the same name but different arguments or parameters.

27. Make a list of things about swing.

1. Change the border, align the text, make your own cursors, dock the toolbars, etc.
2.Large number of controls, including text areas that can show HTML or RTF, trees, tabbed panes, toolbars, and image buttons.
Look and Feel: It lets you change the look and feel of the GUI at runtime, and you can even change the way it looks.
4. It\’s not built on a Windows-based system, so it\’s not too heavy.

28.  What is the JDK?

JDK stands for \”Software Development Kit.\” It has tools like the JVM Compiler, Debugger, Interpreter, and a few others that can be used to make Java Applets and Applications.

29. Make a list of Java\’s features.

1. Dispersed

2. Interpreted

3. Multi-Threaded

4. Platform Independent

5. Object-Oriented

6. Portable

30. How does Java\’s Method Overriding work?

If a Class inherits a Method from an Upper Class, it might be able to make the Method Over Riding work. But the final keyword can\’t be used to declare that method. Function overriding means to change the way an existing method works and what it can do by adding a new type of operation.

31. What does the StringBuffer Class do?

String Class has a StringBuffer Class as part of it. Normal String makes strings with fixed lengths of characters, while the StringBuffer Class makes strings with lengths that can change based on their content and length. So, StringBuffer Class makes better use of memory than String Class.

32. Add Applet Life Cycle Methods to your list.

In an Applet Life Cycle, these are some of the most common methods:
1. init(): This method is used to set up an applet for the first time.
2. start(): This method is used to load the Applet into the System. It is called after the init() method.
3. stop(): The Web browser calls this method to show that the applet is no longer being used.
4. destroy(): When the Browser is shut down, this method is called.

33. What is a Wrapper Class?

Primitive Datatypes can\’t be added directly to a collection, so Wrappers are used to add them. The Java.lang package has classes in the standard library that are similar to Primitive Datatypes. These classes are called Wrappers. Byte, Integer, Short, Long, Character, Boolean, Double, and Float are all types of wrappers.

34. What does a Constructor do?

The main job of a Constructor, which is a special member function, is to set up new objects of its class. When a new object of the same class as the function Object() { [native code] } is made, the function Object() { [native code] } is called. It is called a \”function Object() { [native code] }\” because it builds the values of the class\’s data members. It is unique because both its name and its class name are the same.

35. What is the New Operator?

With a New Operator, you can make a new object or array.
Integer variableInteger = new Integer(25);

36. Use Java\’s Visibility Modifiers.

Here is a list of the Java visibility modifiers:
1. Public: Any method from any class in the same programme can see it.
2. Private: Only functions inside the class can use it. Can\’t get outside of the Class.
3. Protected: Functions in any class in the same package and any subclass anywhere in the programme can call this method.

37. What is javap?

A command called javap is a Disassembler. It basically takes apart a Class file and prints its output to Standard Output. It shows Protected, Public, and Private Fields and Methods, as well as the Packages of the Classes that were passed to it as arguments.

38. In Java, what is an Interface?

In Java, an Interface is just a group of Abstract Methods (Functions). By default, the functions in an Interface are Public. A Class implements the behaviours that are in an Interface. Once an interface is set up, any number of Classes can be used to implement that interface. An Interface is a type of Abstract type by definition.

39. What are Java\’s \”abstract classes\”?

In Java, abstract classes are used to say what subclasses have in common. You can\’t make a copy of an abstract class. But it can be put into a subclass. An Abstract Class helps by giving a model or design for a concrete subclass. If a Class has one or more abstract methods, the whole Class must be declared as abstract.
Syntax: type-name(argument); abstract;

40. What are Java\’s packages?

A package is a group of related types that can be used to manage Access Protection and Name Space. It is basically a container for classes that are used to separate the Name Spaces. There are two kinds of packages in Java: API packages and built-in packages. Packages are used to limit access, avoid naming conflicts, make it easier to use classes and interfaces, and search for or find data.

41. Describe Java\’s Finalize() method.

The finalise() function or method should state clearly what tasks need to be done. So, it is possible to define a method that will be called before the garbage collection mechanism destroys an Object for good. With protected keywords, code in finalise() can\’t be accessed from outside the class. Java does not support destructor.

42. Explain how Java deals with errors.

Basically, an Exception is an Error that happens at Run Time. Java lets the Exception be fixed at Run Time. Exception Handling is the process of finding a solution to an error at run time. So, it gives us a way to find and report Exceptional Circumstances so that the right steps can be taken.

43. What are Java\’s \”Streams\”?

In Java, a Stream is an abstraction that either takes in information or sends it out. A physical device, like Input/Output, is linked to a Stream. Byte Stream, Input Stream, Output Stream, and Character Stream are the main types of streams in Java. An Input Stream takes data from the Source File and sends it to the programme, while an Output File takes data from the programme and sends it to the Destination File.

44. What is javac?

javac is the Java Compiler, which helps turn Java Source Code into Java Byte Code or the.class file. The Java interpreter can then read and run this bytecode, which it turns into machine-specific binary code.

45. Describe Java\’s OutputStream Class.

This class is built on top of the base class OutputStream, which is an abstract class and can\’t be instantiated. With the help of Output Stream Classes, you can Write Bytes, Close the Stream, and Flush Streams.

46. In Java, describe the ByteStream Class and the CharacterSteam Class.

ByteStreams Classes help make it easy to handle how bytes are sent and received. It can be used to read and write binary information. ByteStreams in Java are one-way, which means they can only send data in one direction. Characters Streams are made to handle how characters are put into and taken out of files or input/output.

47. What is a Java Applet?

A Java programme that can be run in a Web browser is called a \”Applet.\” They are mostly made for use on the Internet. It can be put into HTML Web pages, which makes the website more interactive. Applet runs remotely on the client\’s Web browser, but it can\’t use any system resources on the local computer.

48. Get AWT Controls on board.

Here is a list of the AWT controls in Java:
1. Buttons
2. Canvas
3. Select
4. List
5. Label

49. What are Java\’s event listeners?

The Listener Class takes care of the Events that are called by the Graphical User Interface components. It\’s mostly just an interface. It comes from the java.awt.event package. So, it takes care of the things that happen when the User Interface is used. There are many different Listener Interfaces, such as WindowListener, ActionListener, MouseListener, ItemListener, ComponentListener, ContainerListener, and many more.

50. What is javadoc?

Javadoc is a tool that can take Java source code files and turn them into HTML documents. It gives online documentation of Packages and Classes as a result. All tags in javadoc start with the @ symbol. It basically looks through Source Files for Class Methods and Comments.

51. What does a Class mean?

A Class is basically a template for defining how the Objects of that Class should act and what their states are. With a class, all of an object\’s data and code can be turned into a user-defined data type. A Class is a Prototype that defines the Variables and Methods that all Objects of that Class have in common. Objects are Class type variables. Once a Class has been defined, many Objects of that type can be made.

52. What are some ways that object-oriented programming can be used?

OOP can be used in the following areas:
1. Systems with artificial intelligence
2. Simulating and making models
3. Systems that work in real time
4. Parallel programming and neural networks
5. Databases for objects

53. What does encapsulation mean?

Encapsulation is the process of putting data and functions into a single unit called a Class. Data Hiding is the process of hiding data so that the programme can\’t get to it directly. So, the data can\’t be accessed from outside the class; only the functions inside the class can.

54. What is the JRE?

JRE helps get Java programmes to run. It is made up of JVM, Deployment Technologies, Run-Time Class Libraries, and User Interface Toolkits.

55. What is Java\’s Swing?

Swing is mostly a group of graphical parts that can be changed and whose look and feel can be set at run time. Swing is a library that adds on to the AWT. It has new and improved components that work together to make the Graphical User Interface work better. JFC includes swing.

List the different kinds of Java applets.
Here is a list of the different kinds of Java applets:
1. Local Applet: This is an applet that is made and stored on the same computer system where it was made. So, the web page doesn\’t need to be connected to the internet for that web applet to load on the same system.

2. Remote Applet: This is an applet that was made by a third party and is stored on another computer. Millions of people around the world can get to it from their own computers. So, it needs to be able to connect to the internet.

So, that was the list of some important core Java interview questions and answers. If you found something wrong or missing on the list above, please let us know by leaving a comment below.

Related Posts
45+ VB.Net Interview Questions and Answers 2023

Here are 45+ of the most common VB.Net interview questions and answers that will help you pass one of the Read more

50+ HTML Interview Questions and Answers 2023

Here are 50 or more of the most common HTML interview questions and answers that will help you pass even Read more

50+ Python Interview Questions and Answers 2023

Here are 50 or more of the most common Python interview questions and answers that will help you pass one Read more

50+ C++ Interview Questions and Answers 2023

Here are 50+ common C++ interview questions and answers that will help you get through one of the toughest interviews. Read more

50+ PHP Interview Questions and Answers 2023

1. Differentiate between static and dynamic websites. Static Website The content cannot be modified after the script is executed The Read more

Top HR Interview Questions and Answers in 2023

To get your dream job, you need a strong resume and technical skills, but you also need to be able Read more

Interview Advice

The most important Interview Advice for a job candidate in the job interview. If you have an interview, you need Read more

Competency based interview questions and answers

Here we help you with Competency based interview questions and answers list. The candidates are asked competency-based interview questions to Read more

Scroll to Top