Test whether the number is divisible by 7 or not

Test cases: Test cases Expected Result isDivisibleBy7(17) false OK isDivisibleBy7(77) true OK isDivisibleBy7(12) false OK Java solution: public class Program3 { public static void main(String[] args) { Program3.isDivisibleBy7(17); Program3.isDivisibleBy7(77); Program3.isDivisibleBy7(12);…

0 Comments

Check the given number is odd or even

Test cases: Test cases Expected Result testOddEven(12) even OK testOddEven(3) odd OK testOddEven(-55) odd OK Java solution: package test; public class Program2 { public static void main(String[] args) { Program2.testOddEven(12);…

0 Comments

Interview Program – Array

Find the length of unsorted subarray such that sorting this subarray can sort all the array. Print the start and end index. public class Solution { public static void unsortedArrayIndex(int…

0 Comments

Interview Question – Stack

Given a stack containing n elements reverse the stack with the help of an empty stack. import java.util.Stack; public class StackReversal { public static void reverseStack(Stack<Integer> stack) { if (stack.empty())…

0 Comments