Showing posts from August, 2013

How to make thread safe servlet ?

I was asked this question once in an interview Is servlet thread safe ? Luckily they did not drilled much why and how ? I have documented here for the same. Say loudly two times !! Servlet is not thread safe unless we make it. It is developer respo…

Display matrix elements in a spiral order.

Problem :  We have to display elements of matrix in spiral order. For the given matrix mat(4x4).                  In Output order of elements should be  : 1  2  3  11  12  13  9  8  7  4   5  6  Note : solution proposed is valid for matrix of an…

Reverse a string in java via Iterative and recursive approach.

This is very common interview question asked to warm up the interview session specially recursive approach . This problem can be solved in many ways , we will discuss iterative way first followed by recursive approach. Iterative approach :     1.   Us…

Binary tree traversal in Java - Preorder,Inorder,Postorder.

Tree traversal:- In order to process binary tree, the mechanism(different ways) of visiting nodes of tree is termed as tree traversal. Since tree is a non-linear data structure so there are different possible ways to traverse node of trees, as contra…

Servlet life cycle

If you are all set to attend an interview related to J2EE/Java Web application development then, it is recommended to brush up this important concept.I witnessed this question in telephonic round interview. Today I am documenting it for future referen…

Run time complexity- Analysis of loops

Its' the very first thing one should understand before studying algorithm - what is running time complexity of block of code/How to find running time complexity ? For beginner it's very important to understand running complexity for simple loo…

Java puzzle -Set 1

Disclaimer : I do not claim that contents available here are my own , it's compiled by me after reading various pages on internet to make others life easy. :) Happy learning!! Question 1:   Static block trap!! What will be the output of this …

Create a matrix with alternating rectangles of O and X .

Problem :   User will i nputs two numbers m and n and creates a matrix of size m x n (m rows and n columns) in which every elements is either X or 0.                             Solution :  Here outermost layer having X then O then again inner o…

Java puzzle - Set 0

In  java puzzle  series,I am discussing interesting and  intriguing  concept of java. It will include some interview questions and MCQ. Disclaimer :  I do not claim that contents available here are my own , it's compiled by me after reading vario…

Load More
That is All