Tags » Interview Questions

Sample answers to common interview questions.

Although you can’t predict exactly what questions will be asked – you can think about possible questions and prepare BRIEF responses beforehand.

Some questions will be behavioural (on the assumption that past behaviour is a predictor of future behaviour). 991 more words

Job Applications

Java Collection: Best way to remove element?

We should use Iterator to remove element for both List and Set interfaces.

List interface

Assume that you have a list of strings as below… 317 more words

Java

Print the second highest element of an array without using any pre defined functions

$arr = array(1,4,6,12,10,11, 14, 50);
$h = $s = $arr[0];
foreach($arr as $v) {
	if($v > $h) {
		$s = $h;
		$h = $v;
	}
	else if($v > $s) {
		$s = $v;
	}
}

echo $s;
Interview Questions

Write a program to reverse the string without using any pre defined functions

Solution 1

$str = "i love java";
$i = 0;
#getting warning here, so used @ ;) make it work on your own :D
while(@$str[$i] != '')
	$i++;

for($j=$i-1; $j >=0; $j--)
	print $str[$j];
… 32 more words
Interview Questions

ArrayList vs LinkedList

I usually use ArrayList when implement a List interface. Actually, we should use LinkedList in some cases to leverage benefit of each implementation.

So, what are differences between them? 759 more words

Java

Mutable vs Immutable in Java

Question: Java primitive types include 8 elements: byte (8 bit), short (16 bit), int (32 bit), long (64 bit), float (single precision 32-bit IEEE 754 floating point), double (double-precision 64-bit IEEE 754 floating point), boolean, and char (16-bit Unicode char). 225 more words

Java

Difference between String, StringBuffer and StringBuilder in Java

String is immutable while both StringBuffer and StringBuilder is mutable, which means any change e.g. converting String to upper case or trimming white space will produce another instance rather than changing the same instance. 33 more words

Java