Why Choose Java?
1. Industry Proven: Java has been a dominant force in the software
development industry, trusted by many organizations for building
scalable and secure applications. It has established itself as a
reliable toolkit for enterprise-level application development.
2. Open-Source Libraries: Java boasts a vast array of open-source
libraries, providing various approaches to achieving similar
outcomes. This flexibility allows developers to select the best tools
for their specific needs.
3. Competitive Edge: In today’s competitive technology landscape,
developers and engineers are constantly looking for ways to
process information efficiently, extract meaningful insights, and
build models that handle massive datasets. Java’s performance
and scalability make it an ideal choice for these tasks.
4. Versatility: Java is a versatile platform that supports a wide range
of libraries and frameworks, enabling developers to tackle various
tasks, from data processing to application development. Being
well-versed in these libraries will enhance the robustness and
speed of your development work.
1. What is Java Language?
Java is a Object Oriented programming language and platform
independent. So, java is secure and reliable for coding mobile apps and
enterprise software to big data applications and server-side
technologies.
2. What is java virtual machine?
Java virtual machine is known as JVM, it allows to run java programs on
any device or operating system based on “write once run anywhere”
principal and all the java programs are compiled for the JVM.
3. Is Java Platform Independent?
Yes, Java is Platform Independent because all APIs compiled into
bytecodes and the virtual machine taking care of bytecode form different
platforms.
4. Explain difference between Heap and Stack memory in Java?
Basically, stack memory is small in size when compared to heap size and
stack having temporary variables and data but heap used large amount
of data. If stack having no space to create new object it throws an error
message like [Link] but if heap size is full it
throws [Link].
5. Explain difference between Instance variable and Local
variable?
Instance variables are declared out side of the class but local variables
are declared inside of method or constructor.
6. What is marker interface?
Marker Interface does not have any method inside. JDK having built in
marker interfaces are Serializable interface, Cloneable interface and
Remote interface.
7. What is functional interface?
Functional interface means it allows only one abstract method and it
provides from the java version 1.8 onwards. We use
@FunctionalInterface annotation to make an interface into fuctional
interface.
We have four type of functional interfaces and these are applied at
multiple situations
Consumer
Predicate
Function
Supplier
8. What is singleton class?
Singleton class allows only one instance of class exist.
Follow some rules for Singleton class
Declare Access modifier must be private for all construtors and static
method returns a reference to the instance.
The instance must be stored into private static variable.
8. What is singleton class?
Singleton class allows only one instance of class exist.
Follow some rules for Singleton class
Declare Access modifier must be private for all construtors and static
method returns a reference to the instance.
The instance must be stored into private static variable.
9. What is subclass?
A class that derived from another class or parent/super class is known as
subclass.
10. What is constructor in java?
A construcor is special method of class and the declare same name of
class if required. Whenever object is created the constructor
automatically called.
Construcor does not have any return rype and it calls only once at the
time of object creation.
11. What are the various types of interfaces in java?
There are mainly three types of interfaces
1. Noramal interface
Examples: List, Set, Map
2. Functional interface
Example: Runnable
3. Marker interface
Example: Serilizable interface
12. What is the difference between Set and List?
The major difference is List allows duplicate values but Set does not
allows duplicate values and List allows multiple null values but set
allows only one null value.
13. What is linked list?
Linked list is one of linear data structure and data and next node
consider as single node. Where single node stores the data and address
of the next node and the last node is contains NULL value.
Different types of Linked list
1. Single Linked list
2. Double Linked List
3. Circular Linked List
14. What is ArrayList?
ArrayList is a class implemented by using List interface. The
functionality of ArrayList is dynamic array and there is no fixed size of
an array. ArrayList is found in [Link] package. It contains duplicate
values and maintain insertion order. By using add() method to add new
elements into ArrayList
Syntax:
ArrayList<E> al = new ArrayList<E>();
Example:
ArrayList<String> al = new ArrayList<String>();
15. What is Deque?
DeQue stands for Double-ended-queue, it is linear data structure which
allows the data manipulation the data from both the ends.
16. What is TreeSet?
TreeSet is a class which provides an implementation of Set interface and
stored the elements or objects in ascending order.
Syntax:
TreeSet<E> tree = new TreeSet<E>();
17. What is Iterator in java?
Iterator is a loop for collection framework to retrieve the elements one
after other by using iterator method. In Iterator we have three methods
called as
next() : It prints next element if present otherwise it throws
NoSuchElementException
hasNext() : It return all the elements available in the collection
remove() : It remove next element in the in iterator.
18. What is hash map?
HashMap is the implementation of Map interface and it stores the data
in the form if key and value pair.
It is availabe in [Link] package. If we try to insert duplicate key and it
will replace the element of correspondent key.
Example of HashMap:
19. What is the super class of Object?
Object is a parent class of all classes in java.
20. What is the difference between method overloading and method
overriding?
Method overloading is compile time polymorphism and method
overriding run time polymorphism.
Method overloading shares more than one method with different
arguments in the class but method overriding is based on inheritance
which develops from parent class.
21. What is the difference between method interface and abstract
class?
Abstract class having abstract and non-abstract methods but interface
having abstract, default and static methods.
Abstract class does not support multiple inheritance but Interface
supports multiple inheritance.
22. Explain Constructor overloading?
Constructor overloading is more than one Constructor with different
parameters of same class name.
23. Can main() method is overloaded in java?
main() method is overloaded but according to java syntax first jvm calls
main method like “public static void main(String[] args)” only
24. What is Lambda function?
Lambda function is commonly known as anonymous function and it is
user defined function without name. In java we have lambda expression
for express instances of functional interfaces.
Lambda Expression are divided into three parts one is Arguments next
Arrow token and Body of Lambda expression
Syntax:
Lambda operator -> body
25. What is polymorphism?
Polymorphism in general known as many forms and we have two types
of polymorphism
1. Run time polymorphism (method overriding) : same name from
different class and this is called as “Late binding”.
2. Compile polymorphism (method overloading) : Same name with
different parameters
26. What is encapsulation?
Encapsulation is one of the fundamental concept of Object-Oriented-
Programming language and we encapsulate both variables(data) and
data(method) in class, In other words this is a process of wrapping the
data and code together in single unit.
Binding the data by using private keyword for variables and to access
the data from setter and getter method.