Wednesday, June 26, 2019

LinkedList problem statement?

Problem statement:
Given a LinkedList as follows, first can you write an algorithm to check whether this LinkedList is 
creating loop or not?
second if yes then how?
1 -> 2 -> 3 -> 4 -> 5 -> 6 ->3

Write an algorithm for the following problem statements !!

Problem statement:
Given two array as follows. 
a1[] = {1, 2, 3, 4, 5}
a2[] = {1, 2, 3, 0, 5}

we need to find out the missing element in second array which is present in first array, but not in second array.

Can you write the algorithm for the following statement?

Problem statement:
Given an array of integer, you need to write an algorithm so that it prints the expected behaviour?

Sample Input:
a[] = {1, 0, 2, 0, 3, 0}

Sample Ouput:

a[] = {1, 2, 3, 0, 0, 0}

Saturday, June 22, 2019

Can you write the code for switch statements using enum in Java SE 8 ?

Problem statement:
Write a program for switch statements using enum in Java.
  1. enum APP {
  2.     Google, Yahoo, Apple, HP
  3. }
  4. public class SwitchStatement {
  5.     public static void main(String[] args) {
  6.         APP c = APP.Google;
  7.         switch (c) {
  8.             case Apple:
  9.                 System.out.println("You choose Apple.");
  10.                 break;
  11.             case Google:
  12.                 System.out.println("You choose Google.");
  13.                 break;
  14.             case Yahoo:
  15.                 System.out.println("You choose Yahoo.");
  16.                 break;
  17.             case HP:
  18.                 System.out.println("You choose HP.");
  19.                 break;
  20.             default:
  21.                 System.out.println("default");
  22.                 break;
  23.         }
  24.     }
  25. }
Output:
You choose Google.

what are the data types we cannot use in switch statement?

Problem statement:
what are the data types you cannot use as a parameter variable for switch statements in Java 8?

Following are the data types we cannot use as an input parameter variable for switch() statements.
  1. long
  2. float
  3. double
Error: Incompatible type found long, float and double.

public class SwitchStatement {
    public static void main(String[] args) {
        double d = 10.5d;
        switch (d) {
            case 10.5d:
                System.out.println("double");
                break;            
            default:
                System.out.println("default");
                break;
        }
    }
}
Error: Incompatible types. Found: 'double'

what are the data types we can use in switch statement?

Problem statement:
what are the data types you can use as a parameter variable for switch statements in Java 8?
Following are the data types we can use as an input parameter variable for switch() statements.
  1. byte
  2. short
  3. int
  4. char
Add-On:
  1. String 
  2. enum

How to run standalone mock server on local laptop

 Please download the standalone wiremock server from Direct download section at the bottom of the page.  Download and installation Feel fre...