FinaTel – Technical Test Questions – Especially for freshers

FinaTel – Technical Test Questions –  Especially for freshers

This blog explains about FinaTel – Technical Test Questions –  Especially for freshers  –  Especially for freshers and the questions are discussed for answers and are explained below .

              Here the most common questions are explained in a very  precise manner and so they are easy to underst 

1. Find the 2nd largest and 2 smallest of the given array

IN [ ] = { 10 , 2 , 8 , 3 , 5 , 11 , 4 , 15 }

 SOLUTION :

  1. import java.util.Scanner;
  2. public class SecondLargest_Smallest
  3. {
  4.     public static void main(String[] args) 
  5.     {
  6.         int n, temp;
  7.         Scanner s = new Scanner(System.in);
  8.         System.out.print("Enter no. of elements you want in array(Minimum 2):");
  9.         n = s.nextInt();
  10.         int a[] = new int[n];
  11.         System.out.println("Enter all the elements:");
  12.         for (int i = 0; i < n; i++) 
  13.         {
  14.             a[i] = s.nextInt();
  15.         }
  16.         for (int i = 0; i < n; i++) 
  17.         {
  18.             for (int j = i + 1; j < n; j++) 
  19.             {
  20.                 if (a[i] > a[j]) 
  21.                 {
  22.                     temp = a[i];
  23.                     a[i] = a[j];
  24.                     a[j] = temp;
  25.                 }
  26.             }
  27.         }
  28.         System.out.println("Second Largest:"+a[n-2]);
  29.         System.out.println("Smallest:"+a[0]);
  30.     }
  31. }

Output:

$ javac SecondLargest_Smallest.java
$ java SecondLargest_Smallest
 
Enter no. of elements you want in array(Minimum 2):8
Enter all the elements:
10
2
8
3
5
11
4
15
Second Largest: 11
Smallest: 3

The second largest number is 11 and the second smallest number is 3

_______________________________________________________________________________

2. Find the number is 1234321 is palindrome or not? Should not use String anywhere

A palindromic number is number that remains the same when its digits are reversed.

Step 1

Take the original number and reverse it.

Step 2  

Compare the two numbers. If they are exactly the same then the number is a palindrome.

Is 1234321 = 1234321 ?

Answer:

YES, so that means the number 1,234,321 is a palindrome!

______________________________________________________________________________________

3. In [ a ]  = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 };

 In [ b ] = { 2 , 4 , 7 }

 Is ‘b’ a sub array of a ?

ANSWER : Yes , B is a sub array of A since B = { 2 , 4 , 7 } is contained in A = { 1 , 2 , 3 ,  4 , 5 , 6 , 7 , 8 , 9 } 

If the all elements of ‘b’ presents in ‘a‘, then ‘b’ is sub array of ‘a’

______________________________________________________________________________________

4 .Print the first 20 prime numbers.

We already have a C Program to Print prime numbers in a given range based on Max and Min

PROGRAM:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include<stdio.h>
void main()
{
    int n,i,fact,j;
    printf("Enter the Number");
    scanf("%d",&n);
    printf("Prime Numbers are: \n");
    for(i=1; i<=n; i++)
    {
        fact=0;
        for(j=1; j<=n; j++)
        {
            if(i%j==0)
                fact++;
        }
        if(fact==2)
            printf("%d " ,i);
    }
    getch();
}

 OUTPUT:

Enter the Number 20
Prime Numbers are:
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 . . . so on 
 The first 20 prime numbers are :
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71


______________________________________________________________________________