Take FREE!! Online Mettl Mock Test to Crack TechM and Other Companies Written Exams.
Get Off-Campus Placement Jobs Info !!!
TCS NQT Technical and Managerial Round Interview Questions

Basics Programs in JAVA

    241 / 265

    Find the 4th nearest prime number for a given number n. Write a program for it.

    Input : NA


    Output : NA

    Please Login to view the answer

    242 / 265

    Write a program to generate a simple pattern.
    1
    12
    123
    1234
    123
    12
    1

    Input : 4


    Output :

    Please Login to view the answer

    Tags:SAP Labs

    243 / 265

    Given an array, print the Next Greater Element (NGE) for every element. The Next greater Element for an element x is the first greater element on the right side of x in the array. Elements for which no greater element exist, consider next greater element as -1.

    Input : NA


    Output : NA

    Please Login to view the answer

    Tags:SAP Labs

    244 / 265

    Find the count of prime numbers between l and r where 1 <= l, r <= 10 ^ 9 and those numbers whose digits are not even numbers and digits are less than 5

    Eg :- l = 1
    r = 10

    Input : NA


    Output : NA

    Please Login to view the answer

    245 / 265

    A prime number is a whole number greater than 1 that is divisible only by itself and the number 1.

    Given 'n' (1 <= n <= 100000), find the nth prime number.

    Input : An integer n


    Output :

    Please Login to view the answer

    246 / 265

    A Derangement is a permutation of n elements, such that no element appears in its original position. For example, a derangement of {0, 1, 2, 3} is {2, 3, 1, 0}.

    Given a number n, find the total number of Derangements of a set of n elements.

    Input : 1st Input: n = 2

    For two elements say {0, 1}, there is only one
    possible derangement {1, 0}

    2nd Input: n = 3

    For three elements say {0, 1, 2}, there are two
    possible derangements {2, 0, 1} and {1, 2, 0}


    Output :

    Please Login to view the answer

    247 / 265

    Every character in the input string is followed by its frequency.
    Write a function to decrypt the string and find the nth character of the decrypted string. If no character exists at that positionthen then return "-1".
    For eg:- If the input string is "a2b3" the decrypted string is "aabbb".
    Note: The frequency of encrypted string cannot be greater than a single digit i.e.<10.

    Explanation:

    The decrypted string is "abccc", hence the 5th character in the decrypted string is "c".

    Input : Input Specification:
    Input1: A string.
    Input2:5


    Output :

    Please Login to view the answer

    248 / 265

    Given a number of objects N(non-repetitive object) Find the number of arrangements in which no objects occur at original positions.

    Input : Input1: N, the number of Objects.
    Input1: 3


    Output :

    Please Login to view the answer

    249 / 265

    Consider the following series: 1,1,2,3,4,9,8,27,16,81,32,243,64,729,128,2187…

    This series is a mixture of 2 series - all the odd terms in this series form a geometric series and all the even terms form yet another geometric series. Write a program to find the Nth term in the series.

    The value N in a positive integer that should be read from STDIN. The Nth term that is calculated by the program should be written to STDOUT. Other than value of n th term,no other character / string or message should be written to STDOUT. For example , if N=16, the 16th term in the series is 2187, so only value 2187 should be printed to STDOUT.

    You can assume that N will not exceed 30.

    Input : if N=16


    Output :

    View Answer |  Basics |  Practice Program | Add to Reading List To Reading List | Asked In TCS NQTWipro NLTH |  Experience, Fresher
    Please Login to view the answer

    250 / 265

    Consider the below series : 0,0,2,1,4,2,6,3,8,4,10,5,12,6,14,7,16,8
    This series is a mixture of 2 series all the odd terms in this series form even numbers in ascending order and every even terms is derived from the previous term using the formula (x/2)

    Write a program to find the nth term in this series.

    The value n in a positive integer that should be read from STDIN the nth term that is calculated by the program should be written to STDOUT. Other than the value of the nth term no other characters /strings or message should be written to STDOUT.

    For example if n=10,the 10 th term in the series is to be derived from the 9th term in the series. The 9th term is 8 so the 10th term is (8/2)=4. Only the value 4 should be printed to STDOUT.

    You can assume that the n will not exceed 20,000.

    Input : NA


    Output : NA

    View Answer |  Basics |  Practice Program | Add to Reading List To Reading List | Asked In TCS NQTWipro NLTH |  Experience, Fresher
    Please Login to view the answer




You can practice the basics and standard Basics programs given at page 25, asked at freshers or experienced level job interview. Practice our hand-picked page 25 Basics coding interview questions asked in coding round of various it companies and exams. You can programed these given question in any language, you can post your answer and same time you can review other users answer. It is always recommanded to write your own Basics coding questions answer first and then refer others answers. At this page 25 we have covers all the Basics coding questions in 2020 and previously asked in their Interview round or coding rounds.