Program – simulate or generate unchecked exceptions (java & examples)
1. What is unchecked exception in java? Unchecked exceptions are not checked at compiled time. The unchecked exceptions are not forced […]
1. What is unchecked exception in java? Unchecked exceptions are not checked at compiled time. The unchecked exceptions are not forced […]
Difference between checked and unchecked exceptions in java. Discuss the exception class hierarchy showing checked & unchecked exception in java.
We will discuss the difference between error & exception in java. We will demonstrate exception class hierarchy in java. We
What is OutOfMemoryError ? The OutOfMemoryError is thrown by JVM, when JVM does not have enough available memory, to allocate. OutOfMemoryError falls
Create & simulation deadlock situation using multiple threads (concurrency). Cyclic dependency of resource results in deadlock (example/java)
1. What is throw in java? throw is a keyword in java. When an exceptional or unintended situation occurs in
Three Fruit basket puzzle: There are 3 baskets or boxes containing apples, oranges and mixed fruits (apples and oranges). Apple
100 prisoners & a light bulb puzzle: There are 100 prisoners in the prison cells. Prisoners cannot communicate with each
Way to Heaven or Hell puzzle You are standing in front of two doors, one door leads to heaven and
Let us discuss final, finally and finalize in java with code examples. What is final ? final is a keyword
1. What is immutable class? The class whose state does not change after its construction is called immutable class. There
StringBuilder and StringBuffer are mutable classes StringBuilder & StringBuffer are mostly used, when we expects the modifications in string. e.g. Join two
Given an array containing even and odd number in java. We would like to classify the even and odd numbers.
Given an integer array containing 0 and 1. We would like to sort input array. Zeros will be left end
1. Read file using java 8 lambda stream Given a file, read input file by line by line using lambda
Java 8 has introduced default method for interfaces, which provides the default implementation of method. Prior to java 8 interfaces
1. What is functional interface in java8? The interface having one abstract method is called functional interface. The interface can
1. Functional Interface java 8: The interface having one abstract method is called the functional interface. E.g. Comparator, Runnable interface.
Given user defined object or POJO, we would like to serialize object in java. We will use Externalizable interface, so that
Given an array of integers , find out maximum & minimum number in array using linear search. e.g. input array is { 50,
Given sorted integer array in java. Find or search element/integer in an array using binary search algorithm (with example). Binary
Binary search is a divide and conquer algorithm. Divide and conquer algorithm is process of dividing the input data-set after
Given the sorted linked list, we need to remove duplicates from the linked list. There should not be any duplicate nodes in the linked linked list. Suppose we are given the linked list as shown in Fig 1, there are some duplicate elements in the sorted linked list.
Given the sorted linked list, we need to insert the element or node in the linked list such that linked list remains sorted. Suppose the sorted linked list as shown in Fig 1, We need to find the proper place before we need to insert the new element in the linked list, so that sorted order remains intact.
Given the two sorted linked lists, we need to merge these linked lists into single linked list. The resultant linked list should also in sorted one. Let us take a look into the examples to clear our problem statement.
Given a single linked list, we will delete all nodes of single linked list i.e. We want to delete the
Given a single linked list, count number of times given element exist in a single linked list. e.g. if we want
Given the linked list, we need to reverse a linked list in pairs. We need to reverse the nodes in pair. We need to swap the references of alternate nodes, as a result we will get reversed linked list in pairs.
Given the linked list, we need to find out whether the loop exist in the linked list. We need to find if there is any cycle in the linked list. Let us take an example to elaborate the problem statement. We have shown the linked list in Fig 1.
Given the two linked list, they are intersected at some node. We need to find out the intersection point of these two linked list. We have shown two linked list Linked list 1 and linked list 2, both linked lists are intersected at node 50. We need to find out the node 50 as per our problem statement.