Java Interview Questions
Java Interview Questions
This is Google's cache of https://codewithcurious.com/java-interview-questions/. It is a snapshot of the page as it appeared on 24 Dec 2022 10:36:14 GMT. The current page
Search...
could have changed in the meantime. Learn more.
Java is a general-purpose, Object-oriented programming and most widely used language which was developed by James gosling
in 1990s. It’s system independent language where one can run the compiled byte code in any other system which contains JRE in
it.
Platform Independent – The byte code generated on one computer can run on another system.
Multithreaded – IT enables users to write programs that can perform many tasks at a time.
webcache.googleusercontent.com/search?q=cache%3Ahttps%3A%2F%2Ffanyv88.com%3A443%2Fhttps%2Fcodewithcurious.com%2Fjava-interview-questions%2F&rlz=1C5CHFA_enIN977IN977&oq=cache%3Ahttps%3A%2F%2Ffanyv88.com%3A443%2Fhttps%2Fcodewithcurious.com%2Fjava-intervi… 1/5
17/01/2023, 17:40 java interview questions - CodeWithCurious
Variables are the storage locations which are used to store different types of data. In java there are three types of variables based
on their scope. They are
Local Variables – These are the variables that are declared inside a method
Static Variables – These are the variables when one want to initialize them when the execution of program starts. They are
defined using static keyword.
Instance Variables – These are defined outside methods but inside class.
JDK (Java Development Kit) is a Software Development Environment which is used for developing java programs. JRE (Java
Runtime Environment) is a space which enables users to execute java programs and JVM (Java Virtual Machine) is responsible for
providing the runtime environment in which java compiler generated byte code can be executed.
JIT (Just In Time) Compiler is responsible for compiling code at runtime instead of compiling it during the compile time of the
programs (also known as Ahead-Of-Time). It improves the performance of java programs by compiling the generated byte code
into machine code at run time.
webcache.googleusercontent.com/search?q=cache%3Ahttps%3A%2F%2Ffanyv88.com%3A443%2Fhttps%2Fcodewithcurious.com%2Fjava-interview-questions%2F&rlz=1C5CHFA_enIN977IN977&oq=cache%3Ahttps%3A%2F%2Ffanyv88.com%3A443%2Fhttps%2Fcodewithcurious.com%2Fjava-intervi… 2/5
17/01/2023, 17:40 java interview questions - CodeWithCurious
The main objective of introducing wrapper classes is when one want to convert primitive data types to object types and vice
versa. There are some cases where util package handles only objects then we need to convert the primitive types to objects using
these wrapper classes. The wrapper class for int is Integer, char Character, double-Double etc.
In general access specifiers when we want to restrict the usage of variables under scope. Mainly There are three access specifiers
in java. They are
Protected – These members can be accessible outside package only with the help of child class.
In java the static method is the one which is going to created inside the memory even before initializing the instance(object) of it.
So, as we all know that in java the execution starts from the main method, we need to make sure that the main methods is
called first with the help of declaring it as static method.
Yes, we can execute java program without main method up to JDK 6 by initializing the static block but from JDK version 7 it’s
mandatory to include main method in java program because the JVM finds for main() method in the program first.
webcache.googleusercontent.com/search?q=cache%3Ahttps%3A%2F%2Ffanyv88.com%3A443%2Fhttps%2Fcodewithcurious.com%2Fjava-interview-questions%2F&rlz=1C5CHFA_enIN977IN977&oq=cache%3Ahttps%3A%2F%2Ffanyv88.com%3A443%2Fhttps%2Fcodewithcurious.com%2Fjava-intervi… 3/5
17/01/2023, 17:40 java interview questions - CodeWithCurious
The process of writing the same method in different ways in a single program is known as Method Overloading in Java. The
method can be overloaded in two ways in java one is by changing the number of arguments we are going to pass to that functions
and another way is to change the data type of the arguments.
Final keyword in java is used when we want to make sure that the state/value of the variable or object Shouldn’t be changes once
it’s initialized. So, when final keyword is used in declaration of class then no inheritance is possible, if we declare a method using
final keyword then that method cannot be overridden and finally the final variable cannot be changed once it was initialized.
No, the Java is not a pure object-oriented language. The existence of primitive data types in java language makes it as True
Object-oriented language instead of Pure because the primitive data type literals are considered as values not as objects so to
convert them to objects, they introduced wrapper classes.
Constructors are special methods in java which are invoked when an object is created instead of explicitly calling like general
methods. There are three types of constructors in java
Default Constructor
No argument Constructor
Parameterized Constructor
webcache.googleusercontent.com/search?q=cache%3Ahttps%3A%2F%2Ffanyv88.com%3A443%2Fhttps%2Fcodewithcurious.com%2Fjava-interview-questions%2F&rlz=1C5CHFA_enIN977IN977&oq=cache%3Ahttps%3A%2F%2Ffanyv88.com%3A443%2Fhttps%2Fcodewithcurious.com%2Fjava-intervi… 4/5
17/01/2023, 17:40 java interview questions - CodeWithCurious
As the name indicates singleton class in java refers to a class that can have a maximum of only one instance (object). The main
purpose of introducing them is to restrict the creation of objects.
Java is an object-oriented language because it’s capable of implementing all OOPS concepts when it comes to object-based
languages the objects are pre-defined in them instead of creating them explicitly we’ll simply use them. JavaScript is a good
example of Object based language because even though it has the concept of object but can’t be able to implement OOPS
concepts as Java.
Info Support
Follow Us
For More!
Home Contact us
Privacy Policy
Projects
E books
Blogs
About Us
webcache.googleusercontent.com/search?q=cache%3Ahttps%3A%2F%2Ffanyv88.com%3A443%2Fhttps%2Fcodewithcurious.com%2Fjava-interview-questions%2F&rlz=1C5CHFA_enIN977IN977&oq=cache%3Ahttps%3A%2F%2Ffanyv88.com%3A443%2Fhttps%2Fcodewithcurious.com%2Fjava-intervi… 5/5