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 :
-
import java.util.Scanner;
-
public class SecondLargest_Smallest
-
{
-
public static void main(String[] args)
-
{
-
int n, temp;
-
Scanner s = new Scanner(System.in);
-
System.out.print("Enter no. of elements you want in array(Minimum 2):");
-
n = s.nextInt();
-
int a[] = new int[n];
-
System.out.println("Enter all the elements:");
-
for (int i = 0; i < n; i++)
-
{
-
a[i] = s.nextInt();
-
}
-
for (int i = 0; i < n; i++)
-
{
-
for (int j = i + 1; j < n; j++)
-
{
-
if (a[i] > a[j])
-
{
-
temp = a[i];
-
a[i] = a[j];
-
a[j] = temp;
-
}
-
}
-
}
-
System.out.println("Second Largest:"+a[n-2]);
-
System.out.println("Smallest:"+a[0]);
-
}
-
}
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
______________________________________________________________________________