Hot Topics
IBM Solution
Technical Round
- Question 1
What are the factors you consider while working on a client’s project?
- Answer
Data security
Client satisfaction
Understanding problem
Quick reply
- Question 2
Which programming language you are most comfortable with?
- Answer
Tell the programming language you are most comfortable with as interviewer will ask you questions based on that.
- Question 3
What is the difference between String and String Buffer?
- Answer
String | String Buffer |
1. String is a class which is immutable. | String Buffer is a class which is mutable. |
2. String is fast. | Multi thread access is not possible hence it is slow. |
3. String uses Constant String Pool as storage area. | String Buffer uses heap area as storage area. |
- Question 4
Explain everything about OOP.
- Answer
Important features of OOPs are
Inheritance: It is a concept of Object Oriented Programming in which a new class is created from the existing one.
Polymorphism: Poly means many and morph means form. A concept that enables programmers to assign a different meaning or usage to a variable, function or an object in different context.
Polymorphism can be of two types:
Runtime Polymorphism
Compile Time Polymorphism
Abstraction: Creating a new data type using encapsulated items that is well suited for an application.
Encapsulation: It is called data hiding and encapsulation is the way of packing data and function into a single unit to hide the implementation details of a class from outer world.
Method Overriding: In place of inheritance if the parent class and child class both have the same method signature then child class method overrides the parent class method.
Method Overloading: If a class has more than one method with the same method name with variety of parameter list then method will be overloaded.
Object: Object is the reality of a class.
Class: Class is a blue print of similar type of objects.
Constructor: Constructor is a special member function that is automatically invoked at the time of object creation and does not have any return type.
- Question 5
Tell me the high level logic used behind mapping name and respective ID.
- Answer
The high level logic used behind mapping names to their respective IDs is to create a unique identifier for each name. This is usually achieved through the use of data structures such as dictionaries or hash tables. In these data structures, names are stored as keys and their corresponding IDs as values. When a name is searched for, its key is used to look up the corresponding value (ID) in the data structure. This allows for efficient and fast name-ID mapping and retrieval.
- Question 6
According to you what are the differences between AWS and GCP?
- Answer
AWS | GCP |
1. AWS is offered by Amazon | GCP is offered by Google |
2. Amazon charges per hour basis | Google charges per minute basis |
3. AWS provides limited customization. | Google Cloud Platform provides a wide range of customization for any Instance |
4. Companies using AWS are Netflix, LinkedIn, Facebook, etc. | Companies using GCP are HSBC, Spotify, Snapchat, etc. |
- Question 7
What is normalization?
- Answer
Normalization is process to analyse the given relational schemas based on their functional dependencies and primary key to minimize data redundancy and minimize insertion, deletion and update anomalies.
- Question 8
Asked about merge sort and bubble sort (time and space complexity in best and worst case).
- Answer
Algorithm | Best Time Complexity | Worst Time Complexity | Worst Space Complexity |
Merge Sort | O(nlogn) | O(nlogn) | O(n) |
Bubble Sort | O(n) | O(n^2) | O(1) |
- Question 9
Explain left outer join with example.
- Answer
Left outer join is a method to combine two tables which gives the matching rows and the rows which are in the left table but not in the right table.
Syntax : SELECT Table1.column_name, Table1.column_name, Table2.column_name, Table2.column_name FROM Table1 LEFT OUTER JOIN Table2 ON (Table1.matching_column_name = Table2.matching_column_name)
- Question 10
Explain hashing with example.
- Answer
Hashing is a method of converting data into a fixed-length numerical value, called a hash, which represents the original data. The idea behind hashing is to create a unique representation of the data that can be used to identify it quickly and efficiently.
Here’s a simple example of how hashing can be used for mapping names to IDs:
Create a hash function that takes a name as input and returns a unique hash value. For example, the hash function could add up the ASCII values of the characters in the name and then take the result modulo a prime number to ensure the hash value is within a specific range.
Create a data structure such as a hash table, where the hash values generated by the hash function are used as indices to store the corresponding names and IDs.
To map a name to an ID, use the hash function to generate a hash value for the name, then use that value as an index in the hash table to look up the corresponding ID.
To retrieve the ID for a given name, use the same hash function to generate the hash value for the name, then use that value as an index in the hash table to look up the corresponding ID.
In this example, the hash function provides a quick and efficient way to map names to IDs and retrieve the IDs for a given name.
- Question 11
Asked about keys in DBMS (Super, Foreign, Composite).
- Answer
Super key – It is a combination of all possible attributes which can uniquely identify two tuples in a table. It can be also referred to as super set of any candidate key.
Foreign key – It is an attribute or a set of attributes that references to primary key of same table or another table.
Composite key – A primary key that consist of more than one attribute.
- Question 12
Virtual function and polymorphism.
- Answer
Virtual function is a C++ concept where we create a member function using virtual keyword in the base class. It is resolved late at runtime and hence the main use of virtual function is to achieve runtime polymorphism.
Polymorphism is the ability of a class that can be displayed in different forms. Poly means many morphs mean forms.
- Question 13
What is DBMS?
- Answer
It is a collection of programs that enables users to create and maintain a database. In other words, it is a general purpose software that provides the user with the processes of defining, constructing and manipulating the database for various applications.
- Question 14
What are DDL, DML, DCL, TCL?
- Answer
DDL | DML | DCL | TCL | |
Full form | Data Definition Language | Data Manipulation Language | Data Control Language | Transaction Control Language |
Definition | It is a set of SQL commands that is used to create, modify and delete the structures of database | It is a set of commands that is used to manipulate the data i.e. present in the database. | This set of commands deal with the rights, permission and other controls of the database. | It is a set of tasks into single execution unit. It has only two results : success or failure. |
Commands | CREATE, ALTER, DROP, TRUNCATE, RENAME | SELECT, INSERT, UPDATE, DELETE | GRANT, REVOKE | COMMIT, ROLLBACK, SAVE POINT |
- Question 15
Difference between DROP and TRUNCATE.
- Answer
DROP | TRUNCATE |
1. If we want to delete the whole table structure we use DROP command. | We use this command to delete all the rows in a table at one go. |
2. Syntax : DROP from Table_name | Syntax : TRUNCATE Table_name |
- Question 16
What is function overloading?
- Answer
Function overloading in Java is when we have multiple functions with same name but different parameters.
- Question 17
Explain different types of access specifiers.
- Answer
Different types of access specifiers in Java are:
public
private
protected
default
Access Specifier | Public | Private | protected | default |
Same Class | YES | YES | YES | YES |
Same Package Subclass | YES | NO | YES | YES |
Same Package non-subclass | YES | NO | YES | YES |
Different package subclass | YES | NO | YES | NO |
Different package non-subclass | YES | NO | NO | NO |
- Question 18
Print out an array in the form of JSON.
- Answer
Here’s an example of how you could print out an array in the form of JSON in Python:
In this example, the json
module’s dumps
function is used to convert the array into a JSON formatted string, which is then printed out. The dumps
function takes the array as an argument and returns a string representation of the array in JSON format.
- Question 19
Pseudo code of how to delete a node from doubly linked list.
import json
array = [1, 2, 3, 4, 5]
print(json.dumps(array))
#output:[1,2,3,4,5]
- Answer
Here’s a pseudo-code for deleting a node from a doubly linked list:
function deleteNode(node):
if node is None:
return
if node.prev is not None:
node.prev.next = node.next
if node.next is not None:
node.next.prev = node.prev
In this pseudo-code, the deleteNode
function takes a node as an argument and removes it from the doubly linked list. The function first checks if the node is None
, in which case it returns without doing anything. If the node is not None
, the function updates the next
and prev
pointers of the surrounding nodes to skip over the node being deleted. This effectively removes the node from the list while maintaining the integrity of the doubly linked list.
- Question 20
Minimum number of cuts required to cut a cake in 8 equal parts.
- Answer
Step 1: Cut the cake into 4 pieces using 2 cuts.
Step 2: Stack all the 4 pieces.
Step 3: Finally with the third cut just cut the stack of 4 pieces to get 8 pieces in minimum number of cuts.
- Question 21
How to measure 45 minutes given 2 strings of equal length and that they burn in one hour?
- Answer
Start burning one rope which will take 30 minutes to burn totally. Take the second rope and start burning it from both the ends simultaneously, this way you will burn the second rope in 15 minutes. Both ropes burn out in 30 + 15 minutes = 45 minutes.
- Question 22
Given L and R we have to give the sum of L to R in an array.
#include <iostream>
using namespace std;
int main() {
int arr[5],sum=0;
for(int i=0;i<5;i++){
cin>>arr[i];
}
for(int i=0;i<5;i++){
sum+=arr[i];
}
cout<<sum<<endl;
return 0;
}
/*
output:
3
4
6
3
7
23
*/
- Question 23
How much would you rate yourself in programming languages you know?
- Answer
Rate yourself on the basis of how much confident you are with a certain programming language.
- Question 24
What is the difference between abstraction and encapsulation?
- Answer
Abstraction | Encapsulation |
1. Abstraction is a property by virtue of which only essential details are displayed to the user. | Encapsulation is the property that wraps up data in a single unit. |
2. Abstraction can be obtained by using abstract class and interfaces. | Encapsulation is achieved by using access modifiers such as public, private, protected & default. |
3. The object that helps to perform abstraction are encapsulated. | The object that helps in encapsulation is not abstracted. |
4. Abstraction focus on what needs to be done. | Encapsulation focuses on how it needs to be done. |
- Question 25
How can we achieve abstraction in Java?
- Answer
Abstraction is method where essential elements are displayed to the user and important elements are kept hidden.
In Java we can achieve abstraction using abstract keyword before classes and interfaces.
- Question 26
What is a dangling pointer?
- Answer
A dangling pointer is a pointer pointing to a non-existing memory location.