Cognizant GenC Technical Interview Questions

Cognizant GenC Technical Interview Questions and Answers 2022

Find the most asked Cognizant GenC Technical Interview Questions for Freshers on this page.

Page Highlights:-

  • Cognizant GenC Recruitment Process
  • Cognizant GenC Technical Interview Questions
Find nCr and nPr in C

Cognizant GenC Recruitment Process

Cognizant GenC Recruitment Process is divided into the following rounds:-

  • Cognizant GenC Aptitude Round
  • Cognizant GenC Technical Interview
  • Cognizant GenC HR Interview

Cognizant GenC Technical Interview Questions

Question 1:-What are the different types of storage specifiers in C?

Answer:-

  • Auto storage class specifier
  • Static storage class specifier
  • Extern Storage class specifier
  • Register Storage Class specifier

Question 2:-What do you mean by process and thread?

Answer:-

Process is the active instance or executing instance of a program. It is an active instance that resides on the primary memory and leaves the system when rebooted.

Thread is the smallest unit of a process that can be executed. There are multiple threads within a process, with each thread having its task and execution process.

Question 3:-What is a class?

Answer:-

A class represents the common properties and actions of an object. There are three types of access modifiers to control a class:-

  • Public
  • Private
  • Protected

Question 4:- What is Static and Dynamic Binding?

Answer:-

  • Static Binding is a binding in which the name can be combined with the class during collection time, and it is also called early binding.
  • Dynamic Binding is a binding in which name can be identified with the class during execution time, and it is also known as Late Binding.

Question 5:-What are the types of inheritance?

Answer:-

  • Single inheritance
  • Multi-level inheritance
  • Multiple inheritance
  • Multi-path inheritance
  • Hierarchical inheritance
  • Hybrid inheritance

Question 6:- What do you mean by polymorphism?

Answer:-

Polymorphism is the ability of the program to use an operator or function in different ways. There are two types of polymorphism:-

  • Compile-time Polymorphism
  • Runtime Polymorphism

Question 7:- What is the difference between object-oriented programming and object-based programming?

Answer:-

Object-Oriented ProgrammingObject-Based Programming
Does not have built-in objects.Has built-in objects.
Follows all the concepts of oops:- polymorphism, encapsulation, inheritance, abstraction.Does not support all oops concepts. It supports objects and encapsulation.
example – java, cExample- javascript, visual basic

Question 8:- What is a constructor?

Answer:-

A constructor is a method used to initialize the state of an object. It gets invoked at the time of object creation.

Question 9:- What is the try and catch block?

Answer:-

Try and catch block is used in exception handling. The try block defines a set of statements that can lead to an error. The catch block catches the exception.

Question 10:- What is exception handling?

Answer:-

Exception handling is used to manage errors in oops.

Question 11:- Why is macro faster than functions?

Answer:-

When a function is executed, it takes more time to take control from function call to called function. In macros, the expression is directly replaced in the source code. Hence, macro execution is faster than function execution.

Question 12:- What is the difference between DDL and DML commands in DBMS?

Answer:-

DDLDML
It stands for Data Definition LanguageIt stands for Data Manipulation Language
Used to build the databaseUsed to manipulate database
It affects the entire tableIt affects one or more rows
Basic commands:- CREATE, ALTER, DROP, TRUNCATEBasic Commands:- UPDATE, INSERT, MERGE, CALL

Question 13:- What is SDLC?

Answer:-

SDLC stands for Software Development Lifecycle. There are various models used in SDLC to represent the different phases of software development. There are various SDLC models available and developers choose the most suitable one depending on the project.

Types of SDLC models:-

  • Waterfall Model
  • Iterative Waterfall Model
  • Agile Model
  • Spiral Model
  • Prototype Model
  • V model
  • RAD model

Read More:- Software Development Lifecycle

Question 14:- What is the purpose of multithreading?

Answer:-

Multithreading allows concurrent execution of multiple threads which increases the CPU utilization. This helps in making the system multitask.

Read More:- Multithreading

Question 15:- What is indexing?

Answer:-

Indexing allows the users to quickly retrieve records from the database file. There are four types of indexing:-

  • Primary Indexing
  • Secondary Indexing
  • Cluster Indexing
  • Multi-level Indexing

Read More:- Indexing

Question 16:- What are the types of joins?

Answer:-

Joins are broadly categorized into types:-

  • Inner Join
  • Outer Join

Read More:- Joins

Question 17:- What is memory management?

Answer:-

Memory management is the process of handling all memory-related operations in the primary and secondary memory of an operating system. It handles the memory when multiple resources are using the memory.

Read More:- Memory Management

Question 18:- Write a program for bubble sort.

Run
#include 

// Function to print array 
void display(int arr[], int size) 
{ 
    int i; 
    for (i=0; i < size; i++) 
        printf("%d ", arr[i]); 
    printf("\n"); 
} 

// Main function to run the program
int main() 
{ 
    int array[] = {5, 3, 1, 9, 8, 2, 4,7}; 
    int size = sizeof(array)/sizeof(array[0]); 

    printf("Before bubble sort: \n");
    display(array, size);

    int i, j, temp; 
    for (i = 0; i < size-1; i++){       

       // Since, after each iteration right-most i elements are sorted   
       for (j = 0; j < size-i-1; j++) if (array[j] > array[j+1]) 
           {
              temp = array[j]; // swap the element
              array[j] = array[j+1]; 
              array[j+1] = temp; 
           }
    }
    printf("After bubble sort: \n"); 
    display(array, size); 
    return 0; 
}
Run
// Time Complexity : O(N^2)
// Space Complexity : O(1)
class Main
{
    static void bubbleSort(int a[])
    {
        int len = a.length; // calculating the length of array
        for (int i = 0; i < len-1; i++)
            for (int j = 0; j < len-i-1; j++) if (a[j] > a[j+1]) //comparing the pair of elements
                {
                    // swapping a[j+1] and a[i]
                    int temp = a[j];
                    a[j] = a[j+1];
                    a[j+1] = temp;
                }
    }

    /* Prints the array */
    static void printArray(int a[])
    {
        int len = a.length;
        for (int i = 0; i < len; i++)
            System.out.print(a[i] + " "); //printing the sorted array

        System.out.println();
    }

    // Main method to test above
    public static void main(String args[])
    {
        int arr[] = {64, 34, 25, 12, 22, 11, 90};

        bubbleSort(arr);//calling the bubbleSort function

        System.out.println("Sorted array");

        printArray(arr); //calling the printArray function
    }
}

Output

Sorted array
11 12 22 25 34 64 90 
Run
#include 
using namespace std;

void swap(int *var1, int *var2)
{
    int temp = *var1;
    *var1 = *var2;
    *var2 = temp;
}
//Here we will implement bubbleSort.
void bubbleSort(int arr[], int n)
{
   int i, j;
   for (i = 0; i < n-1; i++)
       //Since, after each iteration rightmost i elements are sorted.
       for (j = 0; j < n-i-1; j++) if (arr[j] > arr[j+1])
               swap(&arr[j], &arr[j+1]);
}
// Function to print array.
void display(int arr[], int size)
{
    int i;
    for (i=0; i < size; i++)
        cout << arr[i] << "\t";
        
    cout<<endl;
}
//Main function to run the program.
int main()
{
    int array[] = {5, 3, 1, 9, 8, 2, 4,7};
    int size = sizeof(array)/sizeof(array[0]);
    
    cout<<"Before bubble sort: \n";
    display(array, size);//Calling display function to print unsorted array.
    
    bubbleSort(array, size);
    
    cout<<"After bubble sort: \n";
    display(array, size);//Calling display function to print sorted array.
    
    return 0;
}

Question 19:- Write a program for the Fibonacci series.

Question 20:- Write a program for string reversal.