Skip to main content

Want to Crack Java Coding Interview? Here is 4 Steps to follow - BlogonCode

Coding Interview in Java - Top four things to follow

Point to prepare before going to coding interview in Java

As a Developer, we all have to go through coding interview for any level job. So here we will seen how we can crack coding interviews.

Point to prepare before going to coding interview in Java :

  1. Java in-built classes and its methods
  2. Java collection framework and its hierarchy
  3. Data structure and algorithms
  4. Follow coding standards

1. Java in-built classes and its methods

Java have so many in-built classes and its method like, String, StringBuffer, StringBuilder, Array, etc.

These classes and its methods is so useful in our every coding life. So before coding interview, we must have to gain knowledge about classes and its frequently used methods.

  1. String : length(), split(), charAt(), indexOf(), equals(), trim().
  2. Array : sort(), length (not a method).
  3. Math : abs(), pow(), max(), min().
  4. System  
  5. Scanner

These are just a few examples of Java in-built classes and their methods. Java has a rich set of classes and libraries to help us to perform a variety of tasks.

2. Java collection framework and its hierarchy

Collection is must to know in Java. We can not imagine java language without collection framework.

Learn more about collection framework and its hierarchy :

Some of the main components of the Java Collection Framework include:

  1. Interfaces : The framework includes several key interfaces, including Collection, List, Set, Map, SortedSet, SortedMap, and Queue.

  2. Classes : The framework also includes several implementation classes, such as ArrayList, LinkedList, HashSet, TreeSet, HashMap, and TreeMap.

  3. Algorithms : The framework provides a set of algorithms for sorting, searching, and manipulating collections, such as sort(), reverse(), shuffle(), and min().

  4. Iterators : The framework provides an efficient way of iterating through collections with the Iterator interface and its implementation classes.

Learn more about Iterator in Java :

3. Data structure and Algorithms

  1. Arrays and Strings:

    • Common string operations such as reversal, palindrome check, string compression, etc.
    • Sorting algorithms like Bubble Sort, Insertion Sort, Quick Sort, and Merge Sort.
    • Searching algorithms like Linear Search and Binary Search.
    • Array data structure such as Dynamic Array, ArrayList, and 2D Array.
  2. Linked Lists:

    • Singly Linked List, Doubly Linked List, and Circular Linked List.
    • Linked List operations such as insertion, deletion, reversal, and merging of two linked lists.
  3. Stacks and Queues:

    • Stack operations such as push, pop, peek, and isEmpty.
    • Queue operations such as enqueue, dequeue, and isEmpty.
  4. Trees:

    • Types of trees such as Binary Tree, Binary Search Tree, AVL Tree, and Heap.
    • Tree operations such as insertion, deletion, traversal, and searching.
    • Applications of trees like searching for a specific node, finding the minimum or maximum node, and creating a balanced tree.
  5. Graphs:

    • Types of Graphs such as Undirected Graph, Directed Graph, Weighted Graph, and Unweighted Graph.
    • Graph algorithms such as DFS, BFS, Dijkstra's Algorithm, and Prim's Algorithm.
  6. Recursion:

    • Understanding the concept of Recursion and how it can be used to solve problems in a simpler manner.
    • Common Recursion problems like Tower of Hanoi, Fibonacci Series, and Backtracking.

4. Follow coding standards

  1. Naming conventions : Use descriptive and meaningful names for variables, methods, and classes. Java uses CamelCase for variables, methods, and classes.

  2. Indentation and White Space : Use proper indentation to make the code more readable. Follow consistent white spacing and line breaks.

  3. Use of Braces : Always use braces for the control statements, even for single-line statements.

These are some of the basic standards to follow while coding in Java. 

 

 

 

 

 

 

 

 

 

 

Comments

Popular posts from this blog

Plus Minus HackerRank Solution in Java | Programming Blog

Java Solution for HackerRank Plus Minus Problem Given an array of integers, calculate the ratios of its elements that are positive , negative , and zero . Print the decimal value of each fraction on a new line with 6 places after the decimal. Example 1 : array = [1, 1, 0, -1, -1] There are N = 5 elements, two positive, two negative and one zero. Their ratios are 2/5 = 0.400000, 2/5 = 0.400000 and 1/5 = 0.200000. Results are printed as:  0.400000 0.400000 0.200000 proportion of positive values proportion of negative values proportion of zeros Example 2 : array = [-4, 3, -9, 0, 4, 1]  There are 3 positive numbers, 2 negative numbers, and 1 zero in array. Following is answer : 3/6 = 0.500000 2/6 = 0.333333 1/6 = 0.166667 Lets see solution Solution 1 import java.io.*; import java.math.*; import java.security.*; import java.text.*; import java.util.*; import java.util.concurrent.*; import java.util.function.*; import java.util.regex.*; import java.util.stream.*; import static jav...

Flipping the Matrix HackerRank Solution in Java with Explanation

Java Solution for Flipping the Matrix | Find Highest Sum of Upper-Left Quadrant of Matrix Problem Description : Sean invented a game involving a 2n * 2n matrix where each cell of the matrix contains an integer. He can reverse any of its rows or columns any number of times. The goal of the game is to maximize the sum of the elements in the n *n submatrix located in the upper-left quadrant of the matrix. Given the initial configurations for q matrices, help Sean reverse the rows and columns of each matrix in the best possible way so that the sum of the elements in the matrix's upper-left quadrant is maximal.  Input : matrix = [[1, 2], [3, 4]] Output : 4 Input : matrix = [[112, 42, 83, 119], [56, 125, 56, 49], [15, 78, 101, 43], [62, 98, 114, 108]] Output : 119 + 114 + 56 + 125 = 414 Full Problem Description : Flipping the Matrix Problem Description   Here we can find solution using following pattern, So simply we have to find Max of same number of box like (1,1,1,1). And ...