JAVA INTERVIEW QUESTIONS

Java is a programming language developed by Sun Microsystems and C++ language is made from the operating system to run the project with perfection. Java is a high-level programming language that helps in developing software for numerous platforms. If you are interested to learn a programming language, Java Training at FITA is the best place to start your career.

  1. What is Java?

It is platform-independent and widely preferred by many users. The API integrations, frameworks, containers, and open source libraries are continuously evolving in Java. The below-mentioned questions and answers are highly important and  it is frequently asked Java Interview Questions.

  1. Who created Java?

Java was first created by James Gosling at Sun Microsystems in 1996.

  1. List few important features in Java

Inheritance

Object-oriented

Encapsulation

Polymorphism

  1. What is Inheritance?

Inheritance is a single class that can enlarge into any other classes so that the codes may be reused and the existing class is called as superclass and it the derived class is called a subclass.

  1. What is Encapsulation?

Encapsulation is used to preserve the code from other codes.

  1. What is Object-oriented?

The Object-oriented application is based on creating objects, interacting between the objects and declaring classes.

  1. What is polymorphism

The polymorphism is the one single name and many forms and it is refers to the features of types to act various ways is based on the calling object.

  1. What is the scope of variables in Java?

In Java, the scope of variables is the method of body which is declared and the region of a program is visible that by its name and also can be used.

Java Courses in Chennai at FITA offers professional training to the students and provides a holistic understanding of the concepts. Trainers at FITA have a decade of experience in this field and they clarify the concepts using real-time examples.

  1. What is dynamic in Java

Dynamic is originally things, till was not finalized in the execution and which was happening during the runtime so that Java is considered to be a Dynamic.

  1. What is core Java

The core Java is the group of libraries which are the fragment of standard java installation. Java Se is referred to as Core java.

  1. What are the uses of Java?

Uses of Java programming is used to create web applications, web services, and standalone programs and also to create the Enterprise applications by using Java EE frameworks.

  1. What is the difference between Java and JavaScript?
Java is Object Oriented Programming Language JavaScript is an Object-Oriented Scripting language.
Java code sprint on the browser and         virtual machine. JavaScript code sprint on the browser.
Java source code is to compile of byte code before the JVM will understand and implement it. JavaScript code is don’t need to compile it and it is actually text based.

  1. What is the latest version of Java?

Java 12 is the latest version and it was  released on March 19, 2019.

  1. Distinguish between WAR and JAR files
  WAR   JAR
The WAR files  stand for the WEb Archive files. The JAR files stand for the Java Archive Files
WAR files is responsible for the storage, Java Server pages and XML. JAR files are integrated to the storage, XML and the Java Server pages.
WAR files are used for the Web applications. JAR files are easy to handle the Java classes in a library.

  1. What is the motive of static variables and static methods

When the static method have the requirement to share all the methods or variables between the various objects of a class instead of generating the individual copies for each object.

  1. What are the basic concepts of OOPS

The Object-Oriented Programming System (OOPS) is based on the four important methods or principles.

They are:

Abstraction

Inheritance

Encapsulation

Inheritance

The various applications of Java concepts is the commonly asked Java Interview questions

  1. What is Loops 

Looping is used for the programming to implement the proper statement and the block statement.

  1. What are the types of Loops?

For Loops

While Loops

Do While Loops

  1. What is Final keyword in Java?

A constant is declared by using the final keyword and the value may be assigned after the assignment only once , this value can’t be changed.

  1. What is meant by  Object

Object is an occurence of the class having the instance variables such as object off the state and the behaviour as the method of project and this object is used to create new keyword.

  1. List out the distinguish object based programming language and object-oriented programming languages
object based programming language object-oriented programming languages
Object-oriented programming languages follows the overall concepts of OOPS. Object-based languages doesn’t have the inbuilt objects.
Object-based programming language doesn’t follow all the OOPS concepts. Object-based programming languages have the inbuilt objects.
Example: C++ Example: Java
  1. What is static variable?

The static variable is belongs  to the class, that is  used to refer to the most common property in all the objects. By using static variable makes your program is more efficient.

Java Training in Chennai at FITA provides the students with the necessary training and guidance to the students. Tutors at FITA have a decade of experience in this field and they train the students efficiently in applying the Java programming.

  1. What is static method?

This method does not need to generate the object to invite the static methods and to change the static value is variable.

  1. When should we use serialization?

The serialization is used when the data wants to transmit over the network and by using serialization the object state is converted into the byte stream.

  1. How an object is serialized in Java?

The object is converted into byte stream by serialization in an interface with the serializable name and it is implemented by the class.

  1. What is Serialization?

The serialization is called converting the file into byte stream for the purpose. Here, Serialization is the most frequently asked questions in Java Interview questions for freshers.

  1. Distinguish between Serialization and Deserialization in Java
Serialization Deserialization
The serialization is used for converting the file into byte stream for the purpose. Deserialization is used for the process of opposite serialization where the objects get back from the byte stream.
It is serialized by writing an ObjectOutputStream. It is deserialized by reading an ObjectInputStream.
  1. Why Java is a platform independent programming language?

Java is platform-independent because the byte code that can run on any system irrespective of its underlying operating system.

  1. What are wrapper classes in Java?

Wrapper classes are converted the Java into the reference objects. These are referred to as the Wrapper class because it is wrapped in the primitive data types.

  1. What are constructors

In Java, the constructor refers to the code of block and it is used to initialize an object. It should have the same name as the class.

Two types of constructors

Default constructors

Parameterized constructors

  1. What is Path?

The Path specifies the proper location of .exe files.

  1. How do you print Array in Java?

You may print an array by using the Arrays.toString() also the Array.deep string() methods.

  1. What is a Singleton class?

In Java, a Singleton may have only one instance and its methods are variables. Singleton class methods are useful for the situations.

  1. What is Ternary operator?

The Ternary operator is used to make the correct decision in which the value of the variable is based on the Boolean value evaluation.

  1. How can you generate the random numbers in Java?

By using Math.random() you may create the random numbers in the value of greater than or equal to 0.1 and less than 1.0. This question is asked basically test your knowledge in Java programming.

  1. Explain Default switch case.

In Java, the switch statement is executed in no other switch condition matches are default case.

  1. What are Java packages?

Java package is a collection of libraries and the interfaces that are joined together.

  1. Significance of Java packages

In Java, the packages are used for the developers to generate the code also the group code for re-use purposes.

  1. What is JDK

JDK is Java Development Kit and it is necessary to package the Java programs and also contains the JRE+ development tools.

  1. What is JRE

JRE is the Java Runtime Environment. It refers to the runtime environment, Java byte codes may be executed.

  1. What is JVM

JVM is the Java Virtual Machine also it is abstract machine. Actually, JVM follows three important notations. They are

Implementation

Runtime Instance

Specification

  1. Why Java is not 100% object oriented

Java is not a 100% object-oriented because it uses for the eight primitive data types like char, Boolean, double these are not the object.

  1. List out the advantages of package in Java

They provide easier access control and they contain hidden classes which are not visible to the other outer classes.

  1. Explain ways to pass the arguments in Java

The arguments may be passed as they call by value Java only encourages the call by value and there is no concept of calling by the reference in Java.

  1. What is Super Keyword

The Super Keyword is referred to as the parent class. The Super Keyword carries several uses. They are

Super Keyword used to call the Superclass

Super Keyword could access the method of superclass which has been hidden by the superclass.

  1. What is classloader

In Java, the ClassLoader is the subset of JVM which is responsible for loading the class files, whenever the Java program is implemented and it is first loaded in the class loader.

  1. What are the types of Classloader

Bootstrap ClassLoader

Extension ClassLoader

System/Application ClassLoader

  1. What is class path in Java

The location of Class path is of byte code.

  1. Why string in Java is called as immutable?

In Java, the string is called immutable because it has the value to assign the string and it can’t be changed, a new object is created.

  1. What is Dynamic initialization

The dynamic initialization process is reckoned at the runtime to initialize the changeable and it is the initialization value is variable.

  1. What is Type Casting

When we assign a value of one data type to the different data type then these two data types may not be compatible and needs a conversion. If the Data types are compatible then Java does automatic conversion and does not require casting.

  1. List out the distinguish between Abstract class and interface

The primary difference between an abstract class and interface is that an interface can only possess declaration of public static methods with no concrete implementation while an abstract class can have members with any access specifiers (public, private etc.) with or without concrete implementation.

  1. How can pass arguments to the function by the reference instead of the pass by value

In Java, we can pass an argument to a function only by value and not by reference.

  1. Classes have the multiple constructors?

Class can have multiple constructors with different parameters. The constructor gets used for object creation based on the arguments passed while creating the objects.

  1. Is override static method of a class?

Static methods belong to a class and not to individual objects and are resolved at the time of compilation (not at runtime). Even if we try to override the static method, we will not get a compilation error, nor the impact of overriding when running the code.

  1. Is string is a data type

String is not a primitive data type in java. When a string is created in java, it’s an object of Java.Lang.String class that gets created. After creation of this string object, all built-in methods of String class can be used on the string object.

  1. Why strings are called immutable

In java, string objects are called immutable as once value has been assigned to a string, it can’t be changed and if changed, a new object is created.

  1. What is Multithreading

Multi-threading is a programming concept to run multiple tasks concurrently within a single program. Threads share the same process stack and running in parallel. It helps in performance improvement of any program.

  1. List out the ways of that executes multi-threading

By using Java.Lang.Runnable Interface. Classes implement this interface to enable multi-threading. There is a Run () method in this interface which is implemented.

By writing a class that extend Java.Lang.Thread class.

  1. What is the cause of using break in case of switch statement?

Break is used after each case (except the last one) in a switch so that code breaks after the valid case and doesn’t flow in the proceeding cases too. If break isn’t used after each case, all cases after the valid case also get executed resulting in wrong results.

  1. Can you execute the code even before the main method

If we want to execute any statements before even the creation of objects at load time of class, we can use a static block of code in the class. Any statements inside this static block of code will get executed once at the time of loading the class even before the creation of objects in the main method.

  1. What is the process to make a copy for Java?

We can use the concept of cloning to create a copy of an object. Using Clone, we create copies with the actual state of an object.

Clone () is a method of Clone able interface and hence, Clone able interface needs to be implemented for making object copies.

  1. What is the benefit of using Inheritance?

The key benefit of using inheritance is reusability of code as inheritance enables sub-classes to reuse the code of its superclass. Polymorphism (Extensibility) is another great benefit that allows new functionality to be introduced without affecting existing derived classes.

  1. What is the difference between Queue and Stack?

Stack and Queue both are used as placeholders for a collection of data. The primary difference between a stack and a queue is that stack is based on the Last in First out (LIFO) principle while a queue is based on FIFO (First in First Out) principle.

  1. What is the different states in thread

A thread in Java can be in either of the following states:

Ready

Running

Waiting

  1. In thread programming, which method is a must implementation for all threads?

Run () is a method of Runnable interface that must be implemented by all threads.

  1. How the objects are stored in Java?

In Java, each object when created gets a memory space from a heap. When an object is destroyed by a garbage collector, the space allocated to it from the heap is re-allocated to the heap and becomes available for any new objects.

  1. What is an Anonymous class?

An Anonymous class is a class defined without any name in a single line of code using new keyword.

  1. What is meant by local class?

In Java, if we define a new class inside a particular block, it’s called a local class. Such a class has local scope and isn’t usable outside the block where it’s defined.

  1. What is mean Java string pool?

Java String pool refers to a collection of Strings which are stored in heap memory. In this, whenever a new object is created, String pool first checks whether the object is already present in the pool or not. If it is present, then the same reference is returned to the variable else new object will be created in the String pool and the respective reference will be returned.

  1. What are the various methods of signature?

A method inside a class is the sequence of statement to perform a specific task.

  1. Give a detail about continue and break statement.

The break and continue statements are the most important keywords are used in the loops.

  1. What is a double variable in Java?

In Java, the double always used to take 8 bytes in the memory and it is a double precision decimal number.

  1. What is float variable in Java?

In Java, float takes 4 bytes in the memory and it is a single precision decimal number.

  1. How will you create the random number in java?

By using the Math.random () you may easily create the random numbers in the value of greater than or equal to 0.1 and less than 1.0

  1. What is destructor in Java?

In Java, there are no destructors in the class and it’s own garbage collection mechanisms by destroying the objects when it is longer referenced.

  1. What are the basic classes of all exceptions in Java?

In Java, the superclass is the Java.lang.Throwable of all the exceptions also all classes are referred from this basic class.

  1. What are the uses of final keyword in Java?

Final methods

Final variables

Final class

  1. What is Garbage collection in Java?

The Garbage collection is defined as the objects are allocated dynamically by using the java handles and new operator and where there are no references to an object exist for a long period.

  1. Types of exceptions.

There are two important types of exception. They are

Checked exceptions

Unchecked exceptions

  1. Distinguish between Error and Exception.

Error is the system problem and it always used to occur at a run time also must be resolved in the following to proceed further.

Exception is an input data issue or the wrong logic in the code and it can occur at a compile-time.

  1. Define Final Block.

The Final Block is the code of block which always executes it an exception occurs or not and it follows the try block.

  1. How to create a thread in Java?

To create the thread, follow the two important ways. They are

Implementing the runnable interface

Extending the thread class

  1. Define Daemon thread.

The thread of Daemon threads which does not prevent the JVM from exiting garbage collection for the Daemon thread.  These are

  1. Define Starvation.

Starvation is explaining the situation about where the threads are unable to obtain regular access to resources and it is also unable to make progress

  1. Whether String class is mutable or immutable?

String class is immutable.

  1. Distinguish between Array list and Linked list

Linked list is the storing elements within the dual linked list data structure and the array list is also the storing elements within a dynamical array.

  1. Why the array list is better than the linked list?

Array list can develop dynamically and it can hold the fixed number of elements.

  1. What is Set and List?

Set and list both are child interface of the storing interface.

  1. What is the most important feature of Java?

It is a platform independent language.

  1. Define package.

It is the collection of related interfaces and classes.

  1. Difference between overloading and overriding.

The overloading and overriding methods may sound similar but with different properties Overloading increases the readability of the program and overriding provides specific implementation of the method provided by its super class.

  1. What is String buffer?

StringBuffer is mutable class which means you may change the content later.

  1. What is String?

String is the immutable class which means you cannot modify the content once you have created.

  1. Define Annotations

Java Annotation is the tag which symbolizes that the metadata associated with the interface, methods, class. Etc. The annotation doesn’t directly influence the operations.

  1. Why Java doesn’t use pointers

The pointers are resistant and slightly careless in their use that may result in memory problems and manage their uses.

  1. What is the function of hashcode method

The hashcode method () turns into the hashcode value and also have the same integer number of two keys are the same.

  1. Uses of Synchronized Block

Synchronized helps to lock an object for every resource

The benefit of the synchronized block is smaller in the method.

  1. What is binding in RMI

The binding is the process of registering and associating the name for the object that can be used for further, to look up the remote project.

Basic Java Interview Questions for freshers and experienced.

  1. How to connect a database in Java

The various steps to connect to a database in Java are:

Registering the driver class

Creating the connection

Creating the statement

  1. What is JSTL

JSTL is JSP Standard Tag Library which contains the set of tags for the development process

Code reusability

Fast development

Previous Post: | Next Post:

Quick Enquiry








captcha