FINATEL FRESHER INTERVIEW QUESTIONS WITH ANSWERS

This blog explains about FINATEL FRESHER INTERVIEW QUESTIONS WITH ANSWERS and is given below :

_______________________________________________________________________________

  1. Write a method to convert single dimension array to 2 Dimension array in java programming .  

package com.javajee.Utils;

public class CopyArray {
    
    int[] arr1={1,2,3,4,5,6,7,8,9,10,11,12};
    int rowSize=3;
    int columnSize=4;
    int[][] arr2=new int[rowSize][columnSize];

    public static void main(String[] args) {
        CopyArray CA=new CopyArray();
        CA.copyElems(CA.arr1);
        CA.printElem(CA.arr2);

    }
    
    public void copyElems(int[] A){
        int k=0;
        for(int i=0;i<rowSize;i++){
            for(int j=0;j<columnSize;j++){
                arr2[i][j]=A[k];
                k++;
            }
        }
        
    }
    
    public void printElem(int[][] B){
        for(int i=0;i<rowSize;i++){
            for(int j=0;j<columnSize;j++){
                System.out.print(B[i][j]+” “);                
            }
            System.out.println();
        }
    }

}
_______________________________________________________________________________

 2 . Write a method for number Pattern Programs In Java

Pattern 1:

package com.javainterviewpoint;

 

import java.util.Scanner;

 

public class Pattern1

{

    public static void main(String[] args)

    {

        // Create a new Scanner object

        Scanner scanner = new Scanner(System.in);

 

        // Get the number of rows from the user

        System.out.println(“Enter the number of rows to print the pattern “);

 

        int rows = scanner.nextInt();

        System.out.println(“** Printing the pattern… **”);

        for (int i = 1; i <= rows; i++)

        {

            for (int j = 1; j <= i; j++)

            {

                System.out.print(j + ” “);

            }

            System.out.println();

        }

    }

}

Output

Enter the number of rows to print the pattern

5

** Printing the pattern… **

1

1 2

1 2 3

1 2 3 4

1 2 3 4 5

Pattern 2:

package com.javainterviewpoint;

 

import java.util.Scanner;

 

public class Pattern2

{

    public static void main(String[] args)

    {

        // Create a new Scanner object

        Scanner scanner = new Scanner(System.in);

 

        // Get the number of rows from the user

        System.out.println(“Enter the number of rows to print the pattern “);

 

        int rows = scanner.nextInt();

 

        System.out.println(“** Printing the pattern… **”);

 

        for (int i = 1; i <= rows; i++)

        {

            for (int j = 1; j <= i; j++)

            {

                System.out.print(i + ” “);

            }

            System.out.println();

        }

    }

}

Output

Enter the number of rows to print the pattern

5

** Printing the pattern… **

1

2 2

3 3 3

4 4 4 4

5 5 5 5 5

_______________________________________________________________________________

3 . Write a method to find the count of even digits and sum 

// Java program to find n-th

// Good number.

class GFG 

{

 

    // Function to find kth good number.

    static int findKthGoodNo(int n)

    {

 

        // Find the last digit of n.

        int lastDig = n % 10;

 

        // If last digit is between 

        // 0 to 4 then return 2*n.

        if (lastDig >= 0 && lastDig <= 4)

            return n << 1;

 

        // If last digit is between 

        // 5 to 9 then return 2*n + 1.

        else

            return (n << 1) + 1;

    }

 

    // Driver code

    public static void main(String[] args)

    {

        int n = 10;

 

        System.out.println(findKthGoodNo(n));

    }

}

  Output:

20

Time Complexity: O(1)
Auxiliary Space: O(1)

 METHOD – 2 

import java.util.Scanner;

public class SumOfEvenNumbersInGivenInteger {

private static Scanner scanner = new Scanner(System.in);
private static int n = 0,temp = 0, sum = 0;

public static void main(String[] args)
{
System.out.println(“Enter integer number: “);
n = scanner.nextInt();
if( (n <= 0 ) || !(1 <= n && n <= 1000000)){
System.out.println(“Invalid input!!! please enter valid input.”);
System.exit(0);
}
while( n != 0) {
temp = n%10;
if(temp%2 == 0)
sum +=temp;
n = n/10;
}
System.out.println(“Sum of Even numbers in given integer is : “+sum);
}
}
====================================================================
Output: 
Enter integer number:
2489
Sum of Even numbers in given integer is : 14 

____________________________________________________________________

REFERENCES : 

https://javajee.com/content/copy-an-array-from-1d-to-2d

https://www.javainterviewpoint.com/number-pattern-programs-in-java/

https://www.geeksforgeeks.org/number-even-sum-digits/

http://www.anyforum.in/question/corejava/programming/WAP-to-calculate-sum-of-even-digits-present-in-an-Integer/603