CGI Group
60+ Das cnc Products Interview Questions and Answers
Q1. Frog Jump Problem Statement
A frog is positioned on the first step of a staircase consisting of N
steps. The goal is for the frog to reach the final step, i.e., the N
th step. The height of each step is provided...read more
Calculate the minimal energy required for a frog to travel from the first step to the last step of a staircase.
Iterate through the staircase steps and calculate the energy cost for each jump.
Keep track of the minimum energy cost to reach each step.
Consider jumping either one step or two steps ahead to minimize energy cost.
Return the total minimal energy cost to reach the last step.
Q2. Anagram Pairs Verification Problem
Your task is to determine if two given strings are anagrams of each other. Two strings are considered anagrams if you can rearrange the letters of one string to form the other...read more
Determine if two strings are anagrams of each other by checking if they have the same characters in different order.
Create a frequency map of characters for both strings and compare them.
Sort both strings and compare if they are equal.
Use a dictionary to count the occurrences of each character in both strings and compare the dictionaries.
Q3. Palindromic Substrings Problem Statement
You are given a string 'STR'. Your task is to determine the total number of palindromic substrings present in 'STR'.
Example:
Input:
"abbc"
Output:
5
Explanation:
The pa...read more
Count the total number of palindromic substrings in a given string.
Iterate through each character in the string and expand around it to find palindromic substrings.
Use dynamic programming to store the results of subproblems to avoid redundant calculations.
Consider both odd-length and even-length palindromes while counting.
Example: For input 'abbc', the palindromic substrings are ['a', 'b', 'b', 'c', 'bb'], totaling 5.
Q4. Power Set Generation
Given a sorted array of 'N' integers, your task is to generate the power set for this array. Each subset of this power set should be individually sorted.
A power set of a set 'ARR' is the s...read more
Generate power set of a sorted array of integers with individually sorted subsets.
Iterate through all possible combinations using bitwise operations.
Sort each subset before adding it to the power set.
Handle empty subset separately.
Q5. Pythagorean Triplets Detection
Determine if an array contains a Pythagorean triplet by checking whether there are three integers x, y, and z such that x2 + y2 = z2 within the array.
Input:
The first line contai...read more
Detect if an array contains a Pythagorean triplet by checking if there are three integers x, y, and z such that x^2 + y^2 = z^2.
Iterate through all possible combinations of three integers in the array and check if x^2 + y^2 = z^2.
Use a nested loop to generate all possible combinations efficiently.
If a Pythagorean triplet is found, output 'yes', otherwise output 'no'.
Q6. Intersection of Linked List Problem
You are provided with two singly linked lists containing integers, where both lists converge at some node belonging to a third linked list.
Your task is to determine the data...read more
Find the node where two linked lists merge, return -1 if no merging occurs.
Traverse both lists to find the lengths and the last nodes
Align the starting points of the lists by adjusting the pointers
Traverse again to find the merging point
Q7. Remove Vowels from a String
Given a string STR
of length N
, your task is to remove all the vowels from that string and return the modified string.
Input:
The first line of input contains an integer 'T' represen...read more
Remove all vowels from a given string and return the modified string.
Iterate through each character in the string and check if it is a vowel (a, e, i, o, u or A, E, I, O, U).
If the character is not a vowel, add it to the modified string.
Return the modified string after processing all characters.
Q8. Find All Pairs Adding Up to Target
Given an array of integers ARR
of length N
and an integer Target
, your task is to return all pairs of elements such that they add up to the Target
.
Input:
The first line conta...read more
Given an array of integers and a target value, find all pairs of elements that add up to the target.
Iterate through the array and for each element, check if the target minus the element exists in a hash set.
If it exists, add the pair to the result. If not, add the element to the hash set.
Handle cases where the same element is used twice in a pair.
Return (-1, -1) if no pair is found.
Q9. Preorder Traversal of a BST Problem Statement
Given an array PREORDER
representing the preorder traversal of a Binary Search Tree (BST) with N
nodes, construct the original BST.
Each element in the given array ...read more
Given a preorder traversal of a BST, construct the BST and return its inorder traversal.
Create a binary search tree from the preorder traversal array
Return the inorder traversal of the constructed BST
Ensure each element in the array is distinct
Q10. Spiral Matrix Path Problem Statement
Given a N x M matrix of integers, print the spiral order of the matrix.
Input:
The input starts with an integer 'T' representing the number of test cases. Each test case con...read more
The problem involves printing the spiral order of a given N x M matrix of integers.
Iterate through the matrix in a spiral order by keeping track of the boundaries.
Print the elements in the order of top row, right column, bottom row, and left column.
Continue this process until all elements are printed in the spiral order.
Q11. Concatenate the Largest Digit Problem
You are given three non-zero numbers 'A', 'B', and 'C'. Your task is to determine the number created by concatenating the largest digit found in each number, in the sequenc...read more
Concatenate the largest digit from three numbers to form a new number.
Find the largest digit in each number 'A', 'B', and 'C'.
Concatenate the largest digits in the order 'A', 'B', and 'C' to form the new number.
Return the final concatenated number as the output.
Use multiple threads to print numbers from 1 to 100 in an optimized approach.
Divide the range of numbers (1-100) among the threads for parallel processing.
Use synchronization mechanisms like mutex or semaphore to ensure proper order of printing.
Implement a loop in each thread to print their assigned numbers.
Example: Thread 1 prints 1-25, Thread 2 prints 26-50, and so on.
Ensure proper termination of threads after printing all numbers.
The JVM allocates 5 types of memory areas: Method Area, Heap, Stack, PC Register, and Native Method Stack.
Method Area stores class structures, method data, and runtime constant pool.
Heap is where objects are allocated and memory for instance variables is stored.
Stack stores local variables and partial results, and plays a role in method invocation and return.
PC Register holds the address of the JVM instruction currently being executed.
Native Method Stack contains native metho...read more
UNION combines result sets from two or more SELECT statements, while UNION ALL includes all rows, including duplicates.
UNION removes duplicate rows, while UNION ALL does not
UNION is slower than UNION ALL as it performs a distinct operation
UNION requires the same number of columns in the SELECT statements being combined
Python arrays are a module in Python that allows you to create arrays of a specific data type, while lists are a built-in data structure that can hold elements of different data types.
Arrays in Python are created using the 'array' module and can only store elements of the same data type, while lists can store elements of different data types.
Arrays are more memory efficient compared to lists as they store data in a contiguous block of memory.
Lists have more built-in functions...read more
Retrieve the second highest salary from a database table
Use a SQL query with ORDER BY and LIMIT to retrieve the second highest salary
Example: SELECT salary FROM employees ORDER BY salary DESC LIMIT 1, 1
A program is a set of instructions to perform a specific task, while a process is an instance of a program in execution.
Program is a static entity stored on disk, while process is a dynamic entity in memory.
Program is passive, while process is active and can interact with other processes.
Multiple processes can run the same program simultaneously.
Example: Notepad.exe is a program, while when you open Notepad, it becomes a process.
Pickling is the process of serializing an object into a byte stream, while unpickling is the process of deserializing the byte stream back into an object in Python.
Pickling is used to store Python objects in a file or transfer data over a network.
Unpickling is used to retrieve the original Python objects from the stored byte stream.
The 'pickle' module in Python is used for pickling and unpickling objects.
Example: Pickling a dictionary - pickle.dump(data, file)
Example: Unpickl...read more
Q19. a clock tick 8 times on 8'o clock the time taken between 1st tick and last tick is 35 sec what is the time taken for starting tick and end tick at 11'o colck
The time taken for the clock to tick from 8'o clock to 11'o clock is 105 seconds.
Each tick represents 1/8th of an hour (45 minutes) on the clock.
From 8'o clock to 11'o clock, there are 3 hours, so the total time taken is 3 * 45 = 135 minutes = 135 * 60 = 8100 seconds.
The time taken for the clock to tick from 8'o clock to 11'o clock is 8100 - 35 = 8065 seconds.
A process is an instance of a program running on a computer, while a thread is a smaller unit of a process that can execute independently.
A process has its own memory space, while threads share the same memory space within a process.
Processes are heavyweight, requiring separate memory and resources, while threads are lightweight and share resources.
Processes communicate with each other through inter-process communication mechanisms, while threads can communicate directly with...read more
Q21. What is pass by reference and pass by value
Pass by reference and pass by value are two ways of passing arguments to a function.
Pass by value means a copy of the argument is passed to the function
Pass by reference means the memory address of the argument is passed to the function
Pass by value is used for primitive data types like int, float, etc.
Pass by reference is used for complex data types like arrays, objects, etc.
The 'self' keyword in Python is used to refer to the instance of the class itself.
Used to access variables and methods within a class
Must be the first parameter in a class method definition
Helps differentiate between instance variables and local variables
Example: class MyClass: def __init__(self, x): self.x = x
Example: class MyClass: def display(self): print(self.x)
The __init__ method is a special method in Python classes used to initialize new objects.
The __init__ method is called when a new instance of a class is created.
It is used to initialize the attributes of the object.
Example: class MyClass: def __init__(self, x): self.x = x obj = MyClass(5)
Inheritance in Python allows a class to inherit attributes and methods from another class.
Inheritance is achieved by creating a new class that derives from an existing class.
The new class (subclass) can access the attributes and methods of the existing class (superclass).
Subclasses can also override or extend the functionality of the superclass.
Example: class Dog(Animal) - Dog inherits attributes and methods from Animal class.
Q25. What is the Java code for various types of sorting algorithms?
Various sorting algorithms in Java code
Bubble Sort: int[] arr = {5, 2, 8, 1, 3}; Arrays.sort(arr);
Selection Sort: int[] arr = {5, 2, 8, 1, 3}; Arrays.sort(arr);
Insertion Sort: int[] arr = {5, 2, 8, 1, 3}; Arrays.sort(arr);
Merge Sort: int[] arr = {5, 2, 8, 1, 3}; Arrays.sort(arr);
Quick Sort: int[] arr = {5, 2, 8, 1, 3}; Arrays.sort(arr);
Q26. How to creat web page by using html and css
To create a web page using HTML and CSS, you need to write the structure and content in HTML and then style it using CSS.
Start by creating the basic structure of the web page using HTML tags such as <html>, <head>, <title>, <body>, <header>, <footer>, <nav>, <section>, <article>, <div>, etc.
Add content to the web page using text, images, links, and other elements within the HTML tags.
Use CSS to style the web page by selecting elements with selectors and applying styles such a...read more
Q27. How many times we use for loop in single program
The number of times a for loop is used in a program varies depending on the program's requirements.
The number of for loops used in a program depends on the program's logic and requirements.
For loops are used to iterate over arrays, lists, and other data structures.
Nested for loops are used to iterate over multi-dimensional arrays.
For loops can also be used for counting and other repetitive tasks.
The number of for loops used in a program can range from zero to many.
Q28. Why CGI?
CGI is a leading global IT and business consulting services firm.
CGI has a strong reputation in the industry for delivering high-quality software solutions.
CGI offers a wide range of opportunities for career growth and development.
CGI has a global presence, allowing for exposure to diverse projects and clients.
CGI values innovation and encourages employees to think creatively.
CGI provides a supportive and collaborative work environment.
Q29. How to write excute parameters in function
Execute parameters in a function must be an array of strings.
Define the function with parameters in the parentheses
Separate each parameter with a comma
Enclose the parameters in square brackets to create an array
Example: function myFunction([param1, param2, param3]) { //code here }
Q30. sql query for seleting a particular column from a table and give the employer count
Use SQL query to select a particular column from a table and get the count of entries.
Use SELECT statement to specify the column you want to retrieve.
Use COUNT() function to get the count of entries in that column.
Combine both in a single query to achieve the desired result.
Q31. Why we use class explain with example
Classes are used in object-oriented programming to define a blueprint for creating objects.
Classes provide encapsulation, inheritance, and polymorphism.
They help organize code and make it more reusable.
Example: class Car { String make; int year; }
Example: Car myCar = new Car(); myCar.make = "Toyota"; myCar.year = 2021;
Q32. Why python is a dynamic language
Python is a dynamic language because it allows for runtime changes and doesn't require variable declarations.
Python doesn't require variable declarations, allowing for dynamic typing
Functions and classes can be modified at runtime
Python's built-in functions like type() and setattr() allow for dynamic behavior
Dynamic behavior allows for more flexibility and faster development
Example: changing the type of a variable during runtime
Q33. How to convert dictionary into list
Convert dictionary to list in Python
Use the items() method to get key-value pairs as tuples
Convert the tuples to a list using list()
Append the lists to a new list using append()
Alternatively, use list comprehension to convert the dictionary to a list
Q34. Write sql query to display the avg salary of each dept.
SQL query to display average salary of each department
Use GROUP BY clause to group the results by department
Use AVG() function to calculate the average salary
Join the tables if necessary to get department information
Q35. Write a python program to print every number as even and odd from 0 to 100.
Python program to print numbers from 0 to 100 as even and odd.
Use a for loop to iterate from 0 to 100.
Check if the number is even or odd using the modulo operator.
Print the number along with 'Even' or 'Odd' accordingly.
Q36. Programme on file handling?
A program on file handling is a software that allows users to create, read, update, and delete files on a computer system.
File handling involves operations such as opening, closing, reading, writing, and deleting files.
File handling can be done using various programming languages such as C, C++, Java, Python, etc.
Examples of file handling operations include creating a new file, reading data from a file, writing data to a file, and deleting a file.
File handling also includes c...read more
Q37. What is run time polymorphism ?
Run time polymorphism is the ability of a function to behave differently based on the object it is called with.
Run time polymorphism is achieved through method overriding in object-oriented programming.
It allows a subclass to provide a specific implementation of a method that is already provided by its parent class.
The actual method that gets called is determined at runtime based on the type of object.
Example: Inheritance in Java allows for run time polymorphism when a method...read more
Q38. Write even and odd number code
Code to print even and odd numbers
Use a loop to iterate through numbers
Check if the number is even or odd using modulus operator
Print the number accordingly
Q39. Oops concept examples?
Examples of OOP concepts include inheritance, polymorphism, and encapsulation.
Inheritance: A child class inherits properties and methods from a parent class.
Polymorphism: Objects of different classes can be treated as objects of a common superclass.
Encapsulation: Data and methods are bundled together in a class, hiding internal details.
Q40. Different SQL queries?
Different SQL queries are used to retrieve, manipulate, and manage data in a relational database.
SELECT query: retrieves data from one or more tables
INSERT query: inserts new data into a table
UPDATE query: modifies existing data in a table
DELETE query: removes data from a table
JOIN query: combines data from multiple tables based on a related column
GROUP BY query: groups data based on a specific column
ORDER BY query: sorts data based on a specific column
COUNT query: counts the...read more
Q41. What is anonymous function
An anonymous function is a function without a name.
Anonymous functions are often used as arguments to higher-order functions.
They can be defined using the function keyword or as arrow functions.
Example: const add = function(x, y) { return x + y; }
Example: const multiply = (x, y) => x * y;
Q42. What is inheritance method
Inheritance is a mechanism in object-oriented programming where a class is derived from another class.
Inheritance allows a subclass to inherit properties and methods from a superclass.
The subclass can also add its own properties and methods.
Inheritance promotes code reuse and helps in creating a hierarchical class structure.
For example, a Car class can inherit from a Vehicle class, which can inherit from a Transport class.
The Car class will have access to all the properties a...read more
Q43. What is data structures
Data structures are ways of organizing and storing data in a computer so that it can be accessed and used efficiently.
Data structures are used to manage and manipulate data in computer programs.
Examples of data structures include arrays, linked lists, stacks, queues, trees, and graphs.
Choosing the right data structure for a particular problem can greatly improve the efficiency of a program.
Data structures can be implemented in various programming languages such as C, C++, Jav...read more
Q44. Difference between list and tuple
List is mutable while tuple is immutable in Python.
List can be modified while tuple cannot be modified.
List uses square brackets [] while tuple uses parentheses ().
List is slower than tuple in terms of performance.
List is used for collections of data while tuple is used for grouping related data.
Example of list: [1, 2, 3] and example of tuple: (1, 2, 3).
Q45. Explain about homogeneous elements
Homogeneous elements are elements of the same type or kind.
Homogeneous elements have similar properties and characteristics.
They can be combined or compared easily.
Examples include a set of integers, a group of apples, or a collection of red flowers.
Q46. What is an array
An array is a collection of similar data types stored in contiguous memory locations.
Arrays can be of any data type, such as integers, floats, characters, etc.
Arrays are accessed using an index, starting from 0.
Arrays can be one-dimensional, two-dimensional, or multi-dimensional.
Example: string[] names = {"John", "Jane", "Bob"};
Example: int[] numbers = new int[5];
Q47. Find minimum positive value in array.
Find minimum positive value in array of strings.
Convert array elements to integers
Filter out negative values
Find minimum positive value
Q48. Java code of string manipulation
String manipulation in Java involves various methods like substring, concat, replace, etc.
Use substring() to extract a part of the string
Use concat() to concatenate two strings
Use replace() to replace a specific character or substring in a string
Q49. What is bootstrap
Bootstrap is a popular front-end framework for building responsive websites and web applications.
Bootstrap provides pre-designed HTML, CSS, and JavaScript components for easy implementation
It includes a responsive grid system for creating layouts that adapt to different screen sizes
Bootstrap also offers built-in support for popular JavaScript plugins and libraries
It was originally developed by Twitter and is now maintained by the open-source community
Bootstrap is widely used ...read more
Q50. What are Oops concept ?
Oops concepts are the principles of Object Oriented Programming, including Inheritance, Encapsulation, Polymorphism, and Abstraction.
Inheritance: Allows a class to inherit properties and behavior from another class.
Encapsulation: Bundling data and methods that operate on the data into a single unit.
Polymorphism: Ability of a function to behave differently based on the object it is acting upon.
Abstraction: Hiding the complex implementation details and showing only the necessar...read more
Q51. What is structured query language
Structured Query Language (SQL) is a standard language for managing and manipulating databases.
SQL is used to communicate with databases to perform tasks such as querying data, updating records, and creating tables.
Common SQL commands include SELECT, INSERT, UPDATE, DELETE, and JOIN.
SQL is not case-sensitive, but conventionally written in uppercase for keywords and lowercase for table and column names.
Q52. Explain about Oops concept
OOPs is a programming paradigm based on the concept of objects that interact with each other.
OOPs stands for Object-Oriented Programming.
It focuses on creating objects that have properties and methods.
Encapsulation, Inheritance, and Polymorphism are the three main pillars of OOPs.
Encapsulation is the process of hiding the implementation details of an object from the outside world.
Inheritance allows a class to inherit properties and methods from another class.
Polymorphism allo...read more
Q53. What is encapsulation in Java?
Encapsulation is a mechanism in Java that binds data and methods together, hiding the internal details of an object.
Encapsulation helps in achieving data hiding and abstraction.
It allows the object to control its own state and behavior.
Data members are made private and accessed through public methods (getters and setters).
Encapsulation provides better maintainability, flexibility, and security.
Example: Class with private variables and public methods to access and modify them.
Q54. What is inheritence inJava?
Inheritance in Java allows a class to inherit properties and methods from another class.
Inheritance is a fundamental concept in object-oriented programming.
It promotes code reusability and allows for the creation of hierarchical relationships between classes.
The class that is being inherited from is called the superclass or parent class, while the class that inherits is called the subclass or child class.
The subclass can access the public and protected members of the supercla...read more
Q55. Prime number condition
Prime number is a number that is divisible only by 1 and itself.
Prime numbers are always greater than 1.
Examples of 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.
To check if a number is prime, divide it by all numbers less than or equal to its square root. If none of them divide it evenly, it is prime.
Q56. Explain oops concepts.
OOPs concepts are the principles of Object-Oriented Programming that focus on encapsulation, inheritance, polymorphism, and abstraction.
Encapsulation: bundling of data and methods that operate on that data within a single unit
Inheritance: ability of a class to inherit properties and characteristics from a parent class
Polymorphism: ability of objects to take on multiple forms or behaviors
Abstraction: hiding of complex implementation details and providing a simplified interface...read more
Q57. what is inheritance
Inheritance is a concept in object-oriented programming where a class inherits attributes and methods from another class.
Allows a class to inherit properties and behaviors from another class
Promotes code reusability and reduces redundancy
Derived class can add its own unique attributes and methods
Example: Class 'Car' can inherit from class 'Vehicle' and gain attributes like 'color' and methods like 'drive'
Q58. Write fibanoci code
Fibonacci code generates a series of numbers where each number is the sum of the two preceding ones.
Declare variables for first and second numbers in the series
Loop through the desired number of iterations
Calculate the next number in the series by adding the previous two
Print or store the result
Q59. Features of python
Python is a high-level, interpreted programming language known for its simplicity, readability, and versatility.
Python has a large standard library with modules for various tasks
It supports multiple programming paradigms such as procedural, object-oriented, and functional programming
Python is dynamically typed and garbage-collected
It has a simple and easy-to-learn syntax
Python is widely used in web development, scientific computing, data analysis, artificial intelligence, and...read more
Q60. code reverse a string
Reverse a string using array manipulation
Create an array of characters from the input string
Iterate through the array in reverse order and append each character to a new string
Return the reversed string
Q61. code in inheritance
Inheritance in object-oriented programming allows a class to inherit properties and behaviors from another class.
Inheritance allows for code reusability and promotes a hierarchical structure in classes.
Subclasses can access and modify the properties and methods of their parent class.
Example: class Animal { ... } class Dog extends Animal { ... }
Example: class Shape { ... } class Circle extends Shape { ... }
More about working at CGI Group
Top HR Questions asked in Das cnc Products
Interview Process at Das cnc Products
Top Associate Software Engineer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month