Software Dev. Interview Q&A
Software Dev. Interview Q&A
Difference between JDK, JRE, and JVM: JDK is for development, JRE is for running,
and JVM executes Java code.
Class vs. Object: A class is like a blueprint, and an object is an instance of a class.
Static Keyword: Used for variables/methods that belong to the class, not objects.
Interface vs. Abstract Class: Interface specifies behavior, abstract class can have some
code.
Exception Handling: Handling errors in a program.
Linked List vs. Doubly Linked List: One-way vs. two-way connections.
Servlets:
HTML:
What is the difference between int[] array and int array[] in Java?
There's no difference; both syntax forms are allowed.
String:
What is OOP?
It's a programming paradigm based on objects and classes.
What is encapsulation?
It's the bundling of data and methods that operate on the data into a single unit (class).
What is inheritance?
It's the mechanism that allows one class to inherit properties and behaviors from another
class.
What is polymorphism?
It's the ability of different objects to respond to the same method call in their own way.
What is abstraction?
It's simplifying complex reality by modeling classes based on real-world entities.
Explain the difference between singly linked lists and doubly linked lists.
Singly linked lists have nodes with one reference (next), while doubly linked lists have
nodes with two references (next and previous).
What is hashing?
It's a process of converting data (like a key) into a fixed-size value (a hash code).
What is the time complexity for adding, retrieving, and removing elements in a
HashMap?
O(1) on average, but O(n) in the worst case.
How do you insert and search for an element in a binary search tree?
Insertion maintains the BST property, and searching is done by comparing values at nodes
while traversing the tree.
CODE
1. Print "Hello, World!”
int a = 5, b = 10;
a = a + b;
b = a - b;
a = a - b;
int number = 5;
int factorial = 1;
for (int i = 1; i <= number; i++) {
factorial *= i;
}
int n = 10;
int sum = 0;
for (int i = 1; i <= n; i++) {
sum += i;
}
int n = 10;
int a = 0, b = 1;
System.out.print(a + " " + b + " ");
for (int i = 2; i < n; i++) {
int next = a + b;
System.out.print(next + " ");
a = b;
b = next;
}
return count;
}
}
return count;
}
}