Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Other

Interview questions

Rating
-
Sold
-
Pages
45
Uploaded on
10-01-2026
Written in
2025/2026

Most asking questions in interview in job role as a java developer

Institution
Course

Content preview

Java Interview Questions

, Basic Interview Questions

Q1. What are the data types in Java? Java has two types of data
types:

1.​ Primitive Data Types: These include byte, short, int, long, float, double,
char, and boolean. They store simple values and are not objects.
2.​ Non-Primitive Data Types: These include String, Array, Class, and
Interface. They are derived from primitive data types and provide
more functionalities.


Q2. What are wrapper classes?

Wrapper classes provide an object representation of primitive data types,
such as Integers, Doubles, and Booleans. These classes allow primitives to be
used in collections and provide useful utility methods.


Q3. Are there dynamic arrays in Java?

Java arrays are fixed indynamically. Q4 size. However, ArrayList (from the
Java.util package) provides a dynamic array implementation where elements
can be added or removed dynamically.

Q4. What is JVM?

The Java Virtual Machine (JVM) is a part of the Java Runtime Environment
(JRE). It is responsible for executing Java bytecode by converting it into
machine code specific to the operating system.

Q5. Why is Java platform-independent?

Java achieves platform independence through bytecode. The Java compiler
converts code into bytecode, which the JVM interprets for the underlying OS,
making Java write-once, run-anywhere.

,Q6. What are local and global variables?

●​ Local variables are declared inside methods or blocks and are
accessible only within their scope.
●​ Global variables (also called instance variables) are declared within a
class but outside any method and have a wider scope.


Q7. What is data encapsulation?

Encapsulation is an OOP principle where data (variables) and code (methods)
are bundled into a single unit (class). It restricts direct access to data using
access modifiers (private, protected).

Q8. What is function overloading?

Function overloading allows multiple methods to have the same name but
different parameter lists. The compiler differentiates them based on the
number or type of parameters.

Example:

public class Figure
{
​ public int area(int a, int b)
​ {
​ int rectangleArea = a*b;
​ return rectangleArea;
​ }
​ public int area(int a)
​ {
​ int squareArea = a*a;
​ return squareArea;
​ }
public static void main(String[] args ){
​ Figure f = new Figure();
​ System.out.println("Area of square " + f.area(5));
​ System.out.println("Area of Rectangle " + f.area(5,3));
​ }
}

, Q9. What is function overriding?

Overriding allows a subclass to provide a specific implementation of a
method defined in its superclass. It enables dynamic method dispatch
(runtime polymorphism).

Q10. Why is the main method static in Java?

The main method is static so that it can be called without creating an
instance of the class, allowing the program to start execution without object
instantiation.

Q11. What is the difference between the throw and throws keywords
in Java?

Feature throw throws

Purpose Used to explicitly Declares that a
throw an exception method may throw an
exception

Usage throw new public void
Exception("Error") myMethod() throws
IOException

Number of Exceptions Can throw one Can declare
exception at a time multiple exceptions
using commas

Q12. What do you mean by singleton class?

A singleton class ensures that only one instance of the class exists throughout
the application's lifecycle. It is implemented using a private constructor, a
static instance variable, and a public static method that returns the single
instance. The most common way to create a singleton class is using the lazy
initialization or eager initialization approach.

Q13. Does every try block need a catch block?

No, a try block does not necessarily need a catch block. It can be followed by
either a catch block, a final block, or both. A catch block handles exceptions
that may arise in the try block, while a final block ensures that certain code

Written for

Institution
Course

Document information

Uploaded on
January 10, 2026
Number of pages
45
Written in
2025/2026
Type
OTHER
Person
Unknown

Subjects

$21.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
tejaswiniugale

Get to know the seller

Seller avatar
tejaswiniugale Savitribai Phule pune university
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
4 months
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions