Site icon USA Magazine

Top 14 Java Interview Questions and Answers for freshers 2021

14 Important Java interview questions and Answers for freshers 2021
913 Views

Java is a programming language that hits the top list of all the programming languages and has a huge number of applications like games, desktop applications, and mobile systems among many others, and no less in job opportunities. The following Java Interview Questions for Freshers is here to get you to familiarize yourself with the nature of the question you can experience during your interview.

Here is a list of 14 Important Java Interview Questions for freshers:

1. What is Java?

Answer: Java was developed by James Gosling in June 1991 which is an object-oriented, high-level language that is platform-independent, high performance, and portable programming language.

2. What are the differences between C++ and Java?

Answer: Here is the important difference between C++ and Java:

C++Java
Platform dependent.Platform-independent.
C++ uses compiler onlyJava uses compiler and interpreter both
C++ supports operator overloading and method overloading.Java supports method overloading.
Doesn’t support documentation comments.Supports documentation comment.
Supports pointers.No concept of pointers.
Supports multiple inheritances.Doesn’t support multiple inheritances.

3. List the features of the Java Programming language.

Answer: Here is the features list of Java Programming language

4. Mention some of the different access specifiers for Java classes?

Answer: Access specifiersrefer to the access scope in Java and they are said to be the keywords that are used before a class name.

5. Explain JDK, JRE, and JVM?
Answer: Here is the Difference between JDK, JRF and JVM

JDKJREJVM
Java Development Kit.Java Runtime Environment.Java Virtual Machine.
It is the tool to compile, document, and package Java programs.In JRE Java bytecode can be executed.It is an abstract machine in which java bytecode can be executed.
It contains JRE + development tools.JVM is the implementation that physically exists.JVM follows Specification, Implementation, and Runtime Instance.

6. Mention some of the differences between an Inner Class and a Sub-Class?

Answer: Here are the two major differences between an Inner Class and a Sub-Class

7. What is the static keyword?

Answer: The static keyword is used with methods and to make it global so all the objects will be able to share the same variable. It can also be used with methods.

you can also visit the SQL interview questions.

8. What are finally and finalize in Java?

Answer:

FactorFinallyFinalize
DefinitionFinally is used for Exception HandlingFinalize is used for Garbage Collection
ApplicationFinally the block is used along with a try and catches blockFinalize is used with objects which are no longer in use
FunctionFinally helps in cleaning up the resources used in the try block.Finalize helps in clean up activities before it is destroyed by the garbage collector
ExecutionExecutes right after the execution of try-catch blockIt executes just before an object is destroyed

9. What is Typecasting in Java?

Answer: Typecasting is when we assign a value of one primitive data type to a different primitive data type then these two data types might not be compatible with each other and needs conversion. Syntax: dataType variablename = (dataType) variableToConvert;

10. What is Inheritance?

Answer: Inheritance means one class can acquire another class. The existing class is known as the Superclass whereas the derived class is known as a subclass.


11. What is Encapsulation?
Answer: Purpose of Encapsulation:

Polymorphism means many forms when the same concept is applied in Java it defines as the ability to process objects of various types and classes through a single, uniform interface.

12. Difference between Array and Array List.

Answer: Here are the major difference between Array and Array List:-

ArrayArray List
At the time of array, declaration size is given.   String[] name = new String[2]Size may not be required. It changes the size dynamically.   ArrayList name = new ArrayList
The index is required.   name[1] = “Black”No index required.   name.add(“Black”)
The array is not type parameterizedArrayList in java 5.0 is parameterized.

13.  How to get the database server details in the Java program?

Answer:

14. Name the different modules of the Spring framework?

Answer: There are different modules in the Spring framework:

Exit mobile version