Blog Archives
1 2 3 4 5 6 9

04: 7 Java Collection Quizzes

Q1. When is an object needs to implement the Comparable interface? a) When adding it to a HashSet. b) When adding it to a TreeSet. c) When adding it to …



04: Are Anagrams – Complete the given code

Q. Complete the “areAnagrams(String a, String b)” method so that it returns if two given input strings are anagram or not?



04: Convert Lists to Maps and Maps to Lists with Java 8 power

Why convert from a list to a map? Maps allow you to store and access data by a “KEY”. Lists only allow you to access data by either index or …



04: Tree – Get root to leaf max sum in Java example

Q. Write code to traverse a tree and get the largest “root-to-leaf sum”? A “root-to-leaf sum” is a sum of the node values in a root-to-leaf path.



04: What is wrong with this code? Java Collection & ConcurrentModificationException

Q9. What is wring with this code?



05: Finding the 2nd highest number in an array in Java

Requirements gathering

  1. Does the array allow duplicates?
  2. If duplicates are allowed, then do you need to report duplicates? For example, in {2,4, 6, 3, 6, 5}, is 6 or 5


05: Is a palindrome – complete the given code

Q. Complete the method “isPalindrome(String str) ” which takes a “string” as an input to evaluate if the input is a palindrome?



05: Is it a valid binary search tree (BST) ?

Q. Write code test if a given tree is a binary search tree (i.e. BST)? A. A binary search tree (BST) is a binary tree where each node satisfies the …



05: What is wrong with this code? Deep Vs Shallow comparison & multithreading

Q10 What is wring with this code?



06: Binary Tree – Sum Levels Java Example

Q. Write code to traverse a tree and return the sum of the values (Node.getValue()) of all nodes at the level N in the binary tree?



06: Binary Tree – Get root to leaf max sum in Java example

Q. Write code to traverse a binary tree and get the largest “root-to-leaf sum”? A “root-to-leaf sum” is a sum of the node values in a root-to-leaf path.



06: Change Dir Path – String parsing & working with collections

Q. Complete the method ” public DirPath cd(String newPath)” which applies the following rules: /   : starting with “/” means root directory, else next directory path. ../ : means go …



06: What is Wrong with this code? Multithreading & wait/notify

An excellent written test question to assess your Java multi-threading knowledge. Please practice it by doing it yourself.

Q. Review the code shown below and then answer the following questions.



1 2 3 4 5 6 9

300+ Big Data Interview Questions - FAQs

300+ Java Interview Questions - FAQs

Tutorials on Java & Big Data