print 1 to 10 without using loop in java

public class PrintNumberWithoutLoop {

	public static void main(String[] args) {
		printNumberWithoutLoop(1);

	}

	private static void printNumberWithoutLoop(int i) {
		
		if (i <= 10) {
		
		System.out.println(i);

		printNumberWithoutLoop(i + 1);

		}

	}

}

output

1
2
3
4
5
6
7
8
9
10

count occurrences of character in string java

   
 public class countOccurChar {
    public static void main(String[] args) {
     String strCountString = "Ravi is going to mumbai"; 
    int count = 0;
    char ch = 'a';
    for(int i=0; i
    {
     if(strCountString.charAt(i) == 'i')
         {
            count++;
         }
    }
System.out.println(strCountString+" contains of count "+count+" of "+ch);>
}
}

Output

Ravi is going to mumbai contains of count 4 of a

pyramid shape program in java

public class PyramidShap {
	public static void main(String[] args) {
		int maxLength=6;
		int spaceLenth = maxLength -1;
		
		for(int i=1; i<=maxLength ; i++)
		{
			for(int spc=1; spc<=spaceLenth; spc++)
			
				System.out.print(" ");
				for(int n=1; n
				{
					System.out.print(n+" ");
				}
				spaceLenth--;
				System.out.println();
			
		}
	}

}

output

    1 
   1 2 
  1 2 3 
 1 2 3 4 
1 2 3 4 5 

separate odd and even numbers in java

import java.util.Arrays;

public class OddEvenSeprate {
	public static void main(String[] args) {
		int[] arr = { 1, 2, 3, 4, 5, 6, 7, 9 };
		System.out.println("Input array:" + Arrays.toString(arr));
		for (int i = 0; i < arr.length; i++) {
			if (arr[i] % 2 == 0) {
				for (int j = 0; j < arr.length; j++) {
					if (arr[j] % 2 != 0) {
						int temp = arr[j];
						arr[j] = arr[i];
						arr[i] = temp;
					}
				}
			}
		}
		System.out.println("output Array:" + Arrays.toString(arr));
	}

}

output

Input array:[1, 2, 3, 4, 5, 6, 7, 9]
output Array:[2, 4, 6, 9, 7, 5, 1, 3]

Spring4MVC AngularJS1 Example

Spring4MVC AngularJS1 Example

Java Spring with Neo4J Example

Spring with Neo4J Example

Spring AOP Example

Spring AOP Example

Java Interface

A Java interface can only contain method signatures and fields. The interface can be used to achieve polymorphism. In this problem, you will practice your knowledge on interfaces.

You are given an interface AdvancedArithmetic which contains a method signature int divisor_sum(int n). You need to write a class called MyCalculator which implements the interface.

divisorSum function just takes an integer as input and return the sum of all its divisors. For example divisors of 6 are 1, 2, 3 and 6, so divisor_sum should return 12. The value of n will be at most 1000.

Read the partially completed code in the editor and complete it. You just need to write the MyCalculator class only. Your class shouldnot be public.

Sample Input

6

Sample Output

I implemented: AdvancedArithmetic

12

Explanation

Divisors of 6 are 1,2,3 and 6. 1+2+3+6=12.

import java.util.*;
interface AdvancedArithmetic{
  int divisor_sum(int n);
}
class MyCalculator implements AdvancedArithmetic{
    
    public int divisor_sum(int n){
        int total = 0;
        for(int i=1; i<=n;i++){
           if(n%i==0){
            total = total + i;
           }
        }
        return total;
    }
    
}
class Solution{
    public static void main(String []args){
        MyCalculator my_calculator = new MyCalculator();
        System.out.print("I implemented: ");
        ImplementedInterfaceNames(my_calculator);
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.print(my_calculator.divisor_sum(n) + "
");
      	sc.close();
    }
    /*
     *  ImplementedInterfaceNames method takes an object and prints the name of the interfaces it implemented
     */
    static void ImplementedInterfaceNames(Object o){
        Class[] theInterfaces = o.getClass().getInterfaces();
        for (int i = 0; i < theInterfaces.length; i++){
            String interfaceName = theInterfaces[i].getName();
            System.out.println(interfaceName);
        }
    }
}

Harman International Interview Question (19 Jan 2018) TelPhonic

1) What is difference between JPA and Hibernate ?

2) What is cache in hibernate and types of cache ?

3. how do the mapping using annotation using hibernate and jpa ?

4. what is concurrent API in collection?

5) What is arraylist and hashmap ?

6) how hashmap works ?

7) can we put Object as a key in hashMap ? and how we can sort the map of Object key without using Collection API ?

8) what is different way to Implement Thread in java

9) what is future class in Thread ?

10) which of running performance is better Either ArrayList or HashMap?

11) what is spring boot and what is advantage of Spring boot>

12) what is the default server is embedded in spring boot and how can change the server and put different server with spring boot?

13) What is difference between Maven and Gradle ?

14) Can we create own repository of Maven and Gradle . how?

15) what is Micro services and why ?

16) what is the architecture of Micro services and how can you create within 10 minute using spring boot?

17) what is Zuul and Eureka server? and what is the role in Spring Micro Services ?

18) How manage the database in Micro services? if your are using same relation of Primary and Foreign key ?

19) How can you count, how many request has right now on servlet ?

20) How can get Header data of client in Spring Rest API?

21) what is Callables and Futures class?

22) what is difference between lazy loading and eager loading in hibernate?

Harman International Interview Skype Round(24 Jan 2018)

1) What is the main challange in your project ?

2) How do the payment gateway integration?

3)Describe One to many and Many to One Mapping in hibernate with example ?

4) How do the query optimization in sql ?

5) Senario base -> Suppose we do login in gmail account and after opening the inbox, we close the browser and again we open the browser and get login automatically, what is internal working architecuter happening ?

Link
Eng. Ravi Kumar Verma

Simple and dept learning technology is very important part in software development. Same story has been implemented at this site, so learn and implement the inovative things, Thanks

Ravi Kumar Verma