0% found this document useful (0 votes)
3 views2 pages

Java Interview Questions

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Java Interview Questions

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JAVA INTERVIEW QUESTIONS

1. What is JAVA?
Ans:
Java is a high-level, object-oriented programming language developed by Sun Microsystems in
1995. It is widely used for building web applications, mobile applications, and enterprise software
due to its versatility and platform independence.

2. Di erentiate between JDK, JRE, and JVM ?


Ans:
JDK (Java Development Kit): A software development kit that includes tools for developing Java
applications.

JRE (Java Runtime Environment): A part of the JDK that provides the libraries and JVM to run
Java applications.

VM (Java Virtual Machine): An abstract machine that enables Java bytecode to be executed on
any platform.

3. Explain What is an Access Modi er and Tell how many of them are there in JAVA brie y?
Ans:
Access modi ers determine the visibility of classes, methods, and variables. The main access
modi ers are:
public: Accessible from any other class.
private: Accessible only within the same class.
protected: Accessible within the same package and subclasses.

4. Tell about Method Overloading and Method Overriding in Java ?


Ans:
Method Overloading in Java: If a class has multiple methods with same name but with di erent
Parameters, then it is called Method Overloading in Java.
Method Overriding in Java: If a Sub class (or) Child class has the same method as the parent class,
then it is called Method Overriding in Java.

5. What are the main components of a Java program?


Ans:
A Java program typically consists of:
Classes: Blueprints for creating objects.
Methods: Functions de ned within a class that perform operations.
Main Method: The entry point of any Java application, de ned as public static void main(String[]
args).

6. What is the di erence between an abstract class and an interface in Java?


Ans:
Abstract Class: Can have abstract and non-abstract (concrete) methods, instance variables, and
constructors. A class can extend only one abstract class.
Interface: Can have only abstract methods (since Java 8, it can have default and static methods),
constants, and nested types. A class can implement multiple interfaces.

7. Explain Object Oriented Programming and explain di erent types of OOPS Concepts?
Ans:
It is a methodology which is used to design and develop problems using some concepts that are
written in java.
ff
fi
fi
ff
fi
fi
ff
fi
fl
ff
Most of the Programmers around this World use OOP’s as the standard style of Coding as it gives
some advantages:

• It is Reduces the Code.


• It is easy to read and understand when a new person or an employee is given the existing
code to contribute.
• It Contains some software development concepts which are very useful for writing an
ef cient code.
There are six concepts play a major role in OOPS:
1. Class: Collections of Objects is called a class. It is like a BluePrint.
2. Object: The Entity that has a state and Behaviour is called an Object. The instance of a
class is called an Object.
3. Polymorphism: Performing a particular task in different ways is called as Polymorphism.
In Java, we use Method Overiding and Method Overloading to acheive Polymorphism.
4. Abstraction: Hiding the Internal Details and showing only the needed Information which is
needed by the user is called as Abstraction.
5. Encapsulation: Binding the data and the code together within the single unit is called as
Encapsulation.

8. Explain Two Different types of Polymorphism that we use in JPL(Java Programming Language)?
Ans:
Polymorphism can be classi ed into two types based on the time when the call to the object or
function is resolved. They are as follows:
• 1. Compile Time Polymorphism
• 2. Runtime Polymorphism
1) Compile-Time Polymorphism
Compile time polymorphism, also known as static polymorphism or early binding is the type of
polymorphism where the binding of the call to its code is done at the compile time. Method
overloading or operator overloading are examples of compile-time polymorphism.
2) Runtime Polymorphism
Also known as dynamic polymorphism or late binding, runtime polymorphism is the type of
polymorphism where the actual implementation of the function is determined during the runtime
or execution. Method overriding is an example of this method.

9. What di erent types of Inheritance are there?


Ans:
Inheritance can be classi ed into 5 types which are as follows:
1. 1. Single Inheritance: Child class derived directly from the base class
2. 2. Multiple Inheritance: Child class derived from multiple base classes.
3. 3. Multilevel Inheritance: Child class derived from the class which is also derived from
another base class.
4. 4. Hierarchical Inheritance: Multiple child classes derived from a single base class.
5. 5. Hybrid Inheritance: Inheritance consisting of multiple inheritance types of the above
speci ed.

10. Is it always necessary to create objects from class?


Ans:
No. If the base class includes non-static methods, an object must be constructed. But no objects
need to be generated if the class includes static methods. In this instance, you can use the class
name to directly call those static methods.
fi
fi
ff
fi
fi

You might also like