Indiamart Intermesh
10+ India Power Corporation Interview Questions and Answers
Q1. Prime Numbers within a Range
Given an integer N, determine and print all the prime numbers between 2 and N, inclusive.
Input:
Integer N
Output:
Prime numbers printed on separate lines
Example:
Input:
N = 10
Out...read more
Generate and print all prime numbers between 2 and N, inclusive.
Iterate from 2 to N and check if each number is prime
A prime number is only divisible by 1 and itself
Print each prime number on a new line
Q2. 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, find all pairs of elements that add up to the target.
Iterate through the array and for each element, check if the difference between the target and the element exists in a hashmap.
If it exists, add the pair to the result. If not, add the element to the hashmap.
Handle cases where the same element is used twice in a pair.
Return the pairs found or (-1, -1) if no pair is found.
Q3. Queue Using Stacks Implementation
Design a queue data structure following the FIFO (First In First Out) principle using only stack instances.
Explanation:
Your task is to complete predefined functions to suppor...read more
Implement a queue using stacks with enQueue, deQueue, peek, and isEmpty operations.
Use two stacks to simulate a queue - one for enqueueing and one for dequeueing.
For enQueue operation, push elements onto the enqueue stack.
For deQueue operation, if the dequeue stack is empty, transfer elements from enqueue stack to dequeue stack.
For peek operation, return the top element of the dequeue stack.
For isEmpty operation, check if both stacks are empty.
Example: enQueue(5), enQueue(10)...read more
Q4. Print All Permutations of a String
Given an input string STR
, generate and print all possible permutations of the string.
Input:
str
Output:
All permutations of the input string, each on a new line.
Example:
In...read more
Generate and print all possible permutations of a given input string.
Use recursion to generate all permutations by swapping characters in the string.
Maintain a visited array to keep track of characters already used in a particular permutation.
Print each permutation as it is generated.
Handle duplicate characters by skipping swapping if the character is already in the current position.
Q5. Swap Kth Elements in an Array
Given an array ARR
of size N
, perform the operation to swap the Kth element from the beginning with the Kth element from the end of the array.
Example:
Input:
N = 5, K = 2
ARR = [1,...read more
Swap Kth elements in an array with given constraints.
Create a temporary variable to store the Kth element from the start
Swap the Kth element from the start with the Kth element from the end
Return the modified array
Q6. Find Duplicates in an Array Problem Statement
You are provided with an array/list ARR
of size 'N', containing integers ranging from 0 to N - 1. Some elements in this array might be repeating. Your task is to id...read more
Identify duplicate elements in an array of integers ranging from 0 to N-1.
Iterate through the array and keep track of seen elements using a hash set.
If an element is already in the set, it is a duplicate and can be added to the result.
Return the list of duplicate elements found in the array.
Q7. Why java is known as platform independent language?
Java is platform independent because it uses the concept of bytecode and virtual machine.
Java code is compiled into bytecode, which is a platform-independent representation of the code.
The bytecode is then executed by the Java Virtual Machine (JVM), which is specific to each platform.
This allows Java programs to run on any platform that has a compatible JVM.
The JVM acts as an interpreter, translating the bytecode into machine code that can be executed by the underlying hardwa...read more
Q8. What are fundamental pillars of OOPS programming. Explain each of them in detail.
The fundamental pillars of OOPS programming are encapsulation, inheritance, and polymorphism.
Encapsulation: It is the process of hiding the internal details of an object and providing a public interface for interacting with it.
Inheritance: It allows creating new classes by inheriting properties and behaviors from existing classes, promoting code reuse.
Polymorphism: It enables objects of different classes to be treated as objects of a common superclass, providing flexibility a...read more
Q9. Given a list of custom class objects. Write a program to sort that list based on one of its properties.
Sort a list of custom class objects based on one of its properties.
Use a sorting algorithm like bubble sort, insertion sort, or merge sort.
Implement a comparison function to compare the desired property of the objects.
Apply the sorting algorithm to the list of objects using the comparison function.
Q10. Write a SQL query to print number of rows in a table.
A SQL query to count the number of rows in a table.
Use the COUNT() function in SQL to count the number of rows in a table.
Specify the table name in the FROM clause.
Use the result of the COUNT() function to print the number of rows.
Q11. What is exception handling. How to implement it?
Exception handling is a mechanism to handle runtime errors and prevent program crashes.
Exception handling is used to catch and handle errors that occur during program execution.
It involves the use of try-catch blocks to catch exceptions and handle them gracefully.
The try block contains the code that might throw an exception, and the catch block handles the exception.
Multiple catch blocks can be used to handle different types of exceptions.
Finally block can be used to execute ...read more
Compile-time polymorphism is achieved through function overloading and operator overloading, while runtime polymorphism is achieved through virtual functions and inheritance.
Compile-time polymorphism is resolved during compile-time based on the number and types of arguments passed to a function.
Examples of compile-time polymorphism include function overloading, where multiple functions with the same name but different parameters can be defined.
Runtime polymorphism is resolved...read more
The various types of inheritance in Object-Oriented Programming include single inheritance, multiple inheritance, multilevel inheritance, hierarchical inheritance, and hybrid inheritance.
Single inheritance: A class inherits from only one base class.
Multiple inheritance: A class inherits from more than one base class.
Multilevel inheritance: A class inherits from a class, which in turn inherits from another class.
Hierarchical inheritance: Multiple classes inherit from a single ...read more
ACID properties in DBMS ensure data integrity and consistency.
Atomicity: All transactions are either completed in full or not at all.
Consistency: Data must be in a valid state before and after a transaction.
Isolation: Transactions should be isolated from each other until they are completed.
Durability: Once a transaction is committed, changes are permanent and cannot be lost.
Example: If a bank transfer fails midway, the entire transaction is rolled back to maintain atomicity.
Q15. Difference between i++ and ++i through implementation.
i++ and ++i are both increment operators in C++ but have different behaviors.
i++ is a post-increment operator which increments the value of i after using it in an expression.
++i is a pre-increment operator which increments the value of i before using it in an expression.
Example: int i = 5; int a = i++; // a = 5, i = 6; int b = ++i; // b = 7, i = 7;
Q16. Application of stack in real life.
Stacks are used in real life for managing undo operations in text editors, backtracking in maze solving, and managing function calls in programming.
Undo operations in text editors - allows users to go back to previous states of a document
Backtracking in maze solving - helps in keeping track of visited paths and backtracking when necessary
Managing function calls in programming - helps in keeping track of function calls and returning to previous functions
Top HR Questions asked in India Power Corporation
Interview Process at India Power Corporation
Top Associate Software Engineer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month