Cognizant
500+ JBF RAK LLC Interview Questions and Answers
Q101. Why cloud computing is used
Cloud computing is used for scalability, cost-effectiveness, flexibility, and accessibility of resources.
Scalability: Easily scale resources up or down based on demand.
Cost-effectiveness: Pay only for the resources you use, reducing upfront costs.
Flexibility: Access resources from anywhere with an internet connection.
Accessibility: Allows for collaboration and sharing of resources across different locations.
Examples: Amazon Web Services (AWS), Microsoft Azure, Google Cloud Pl...read more
Q102. Find 2nd largest number in the array.
To find the 2nd largest number in an array, we can sort the array in descending order and return the second element.
Sort the array in descending order using any sorting algorithm.
Return the second element of the sorted array as it will be the 2nd largest number.
If the array has less than 2 elements, return an error message.
Q103. 1. what are the 4 main divisions in COBOL. Explain each 2. Explain VSAM Define? 3. what is the purpose of file status clause in Select statement
COBOL main divisions are Identification Division, Environment Division, Data Division, and Procedure Division. VSAM Define is used to define the structure of a VSAM file. File status clause in Select statement is used to handle file operations.
Identification Division - contains program name and author information
Environment Division - specifies the environment in which the program will run
Data Division - defines the data structures used in the program
Procedure Division - cont...read more
Q104. Sorting array using any alogrithm
Sorting an array involves arranging its elements in a specific order.
Choose an appropriate sorting algorithm based on the size and type of data in the array.
Common sorting algorithms include bubble sort, insertion sort, selection sort, merge sort, and quicksort.
Implement the chosen algorithm in code and apply it to the array.
Verify that the array is sorted correctly by checking the order of its elements.
Q105. Error detection in program.
Error detection in program involves identifying and fixing mistakes in the code.
Use debugging tools to identify errors
Check for syntax errors, logical errors, and runtime errors
Test the program thoroughly to ensure all errors are fixed
Q106. What is C Language
C is a high-level programming language used for system programming, embedded systems, and game development.
C was developed by Dennis Ritchie at Bell Labs in 1972.
It is a compiled language that allows for low-level memory manipulation.
C is used for operating systems, device drivers, and firmware.
Examples of C-based software include the Linux kernel, MySQL, and Adobe Photoshop.
C is known for its efficiency and speed, making it a popular choice for game development.
C++ is an ext...read more
Q107. Concept of OOP
OOP is a programming paradigm that uses objects to represent and manipulate data.
OOP stands for Object-Oriented Programming.
It focuses on creating objects that have properties and methods.
Encapsulation, inheritance, and polymorphism are key concepts in OOP.
Examples of OOP languages include Java, C++, and Python.
Q108. Css precendence and priotization in web
CSS precedence determines which styles will be applied to an element when conflicting styles are present.
Inline styles have the highest precedence
Styles in a <style> tag come next
External stylesheets have the lowest precedence
Specificity of selectors also plays a role in determining precedence
Using !important in a style declaration will override all other styles
Q109. Buy and Sell Stock - III Problem Statement
Given an array prices
where the ith element represents the price of a stock on the ith day, your task is to determine the maximum profit that can be achieved at the en...read more
Determine the maximum profit that can be achieved by selling stocks with at most two transactions.
Iterate through the array and calculate the maximum profit that can be achieved by selling at each day.
Keep track of the maximum profit that can be achieved after the first transaction and the maximum profit that can be achieved after the second transaction.
Return the maximum profit that can be achieved after the second transaction.
Q110. Explain four pillars of OOPs
The four pillars of OOPs are Inheritance, Encapsulation, Abstraction, and Polymorphism.
Inheritance: Allows a class to inherit properties and behavior from another class.
Encapsulation: Bundles data and methods into a single unit, protecting data from outside interference.
Abstraction: Hides complex implementation details and only shows the necessary features to the user.
Polymorphism: Allows objects of different classes to be treated as objects of a common superclass.
Q111. Wirte a program of sorting
Program to sort an array of strings
Use a sorting algorithm like bubble sort, insertion sort, or quicksort
Compare adjacent elements and swap them if they are in the wrong order
Repeat until the array is sorted
Example: bubble sort - for i in range(len(arr)): for j in range(len(arr)-i-1): if arr[j] > arr[j+1]: arr[j], arr[j+1] = arr[j+1], arr[j]
Q112. what is semantic html
Semantic HTML is using HTML tags that clearly define the content and structure of a web page.
Semantic HTML helps improve accessibility for users with disabilities.
It also improves SEO by providing search engines with better understanding of the content.
Examples of semantic HTML tags include <header>, <nav>, <article>, <section>, <footer>.
Q113. what are object in JS
Objects in JavaScript are complex data types that can store multiple key-value pairs.
Objects are created using curly braces {}
Keys are strings that represent the property names
Values can be any data type, including other objects or functions
Access object properties using dot notation or bracket notation
Q114. TC questions: Types of datatypes? Predefined functions? Difference between list and tree? Who is more preferred? Difference between class and object? Difference between inheritance and polymorphism? Aptitude qu...
read moreInterview questions for Software Engineer position
Datatypes: int, float, string, boolean, etc.
Predefined functions: print(), len(), range(), etc.
List is linear while tree is hierarchical. Trees are preferred for faster search and insertion.
Class is a blueprint while object is an instance of a class.
Inheritance is a way to create a new class from an existing class while polymorphism is the ability of an object to take on many forms.
Aptitude question on time may involve calcula...read more
Q115. Biggest company in india
Reliance Industries Limited is currently the biggest company in India.
Reliance Industries Limited is a conglomerate with interests in petrochemicals, refining, oil, and gas exploration.
It was founded by Dhirubhai Ambani in 1966 and is currently run by his son Mukesh Ambani.
Reliance Industries Limited is also the second-largest company in Asia by market capitalization.
Other major companies in India include Tata Group, State Bank of India, and Indian Oil Corporation.
Q116. Maximum Difference Problem Statement
Given an array ARR
of N
elements, your task is to find the maximum difference between any two elements in ARR
.
If the maximum difference is even, print EVEN; if it is odd, p...read more
Find the maximum difference between any two elements in an array and determine if it is even or odd.
Iterate through the array to find the maximum and minimum elements
Calculate the difference between the maximum and minimum elements
Check if the difference is even or odd and return the result
Q117. Print Name and Age Problem Statement
Create a class named Person
with a string variable 'name'
and an integer variable 'age'
, such that these variables are not accessible outside the class. Implement a method t...read more
Create a class Person with private variables name and age, and methods to set and get their values.
Create a class Person with private variables 'name' and 'age'.
Implement a method setValue to set the variables' values.
Implement a method getValue to print the variables' values.
Ensure the name is a non-empty string and the age is a non-negative integer.
Encapsulate the data and provide a clear interface for setting and getting the values.
Q118. code for Pattern matching
Pattern matching is the process of finding specific patterns within a larger set of data.
Regular expressions are commonly used for pattern matching.
Pattern matching can be used in programming languages to match specific syntax or structures.
Pattern matching can also be used in data analysis to find trends or anomalies.
Examples of pattern matching include searching for specific words in a document or finding a specific sequence of numbers in a dataset.
Q119. Write program for prime Number
Program to check if a number is prime or not
Create a function to check if a number is prime by iterating from 2 to the square root of the number
If the number is divisible by any number in that range, it is not prime
Handle edge cases like 0, 1, and negative numbers
Q120. SQL Joins and its types
SQL Joins are used to combine rows from two or more tables based on a related column between them.
Types of SQL Joins include INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN.
INNER JOIN returns rows when there is at least one match in both tables.
LEFT JOIN returns all rows from the left table and the matched rows from the right table.
RIGHT JOIN returns all rows from the right table and the matched rows from the left table.
FULL JOIN returns rows when there is a match in one of ...read more
Q121. Encode the Message Problem Statement
Given a text message, your task is to return the Run-length Encoding of the given message.
Run-length encoding is a fast and simple method of encoding strings, representing ...read more
Implement a function to encode a text message using run-length encoding.
Iterate through the message and count consecutive characters
Append the character and its count to the encoded message
Handle edge cases like single characters or empty message
Q122. Minimum Steps for a Knight to Reach Target
Given a square chessboard of size 'N x N', determine the minimum number of moves a Knight requires to reach a specified target position from its initial position.
Expl...read more
Calculate minimum steps for a Knight to reach target position on a chessboard.
Use BFS algorithm to find shortest path from Knight's starting position to target position.
Consider all possible moves of the Knight on the chessboard.
Keep track of visited positions to avoid revisiting them.
Return the minimum number of moves required for the Knight to reach the target position.
Q123. what are different phases of waterfall model?
Waterfall model has five phases: requirements, design, implementation, testing, and maintenance.
Requirements phase: gathering and documenting requirements
Design phase: creating a detailed design based on requirements
Implementation phase: coding and integrating components
Testing phase: verifying that the system meets requirements
Maintenance phase: making changes and updates to the system
Example: building a website using waterfall model
Example: developing a software application...read more
Q124. Why we use redux
Redux is used for managing the state of an application in a predictable way.
Centralized state management
Predictable state changes
Easier debugging and testing
Q125. Swapping two numbers
Swapping two numbers is a basic programming task that involves exchanging the values of two variables.
Create a temporary variable to store the value of one of the variables
Assign the value of the first variable to the second variable
Assign the value of the temporary variable to the first variable
Q126. Oops and its types
Oops stands for Object-Oriented Programming System. Types include syntax errors, logical errors, and runtime errors.
Syntax errors are mistakes in the code that prevent it from running, such as missing semicolons or parentheses.
Logical errors occur when the code runs but produces incorrect results, such as using the wrong formula in a calculation.
Runtime errors happen during the execution of the program, such as dividing by zero or accessing a null object.
Q127. Whether E-commerce shopping safe or not
E-commerce shopping can be safe if proper precautions are taken.
Use secure websites with HTTPS encryption
Avoid public Wi-Fi when making purchases
Check for seller reviews and ratings
Use strong and unique passwords
Monitor credit card statements for any unauthorized charges
Q128. What is Byte code?
Byte code is a compiled code that can be executed on any platform with the help of a virtual machine.
Byte code is an intermediate code that is generated by a compiler.
It is platform-independent and can be executed on any platform with the help of a virtual machine.
Examples of virtual machines include Java Virtual Machine (JVM) and .NET Common Language Runtime (CLR).
Q129. Next Greater Element Problem Statement
Given a list of integers of size N
, your task is to determine the Next Greater Element (NGE) for every element. The Next Greater Element for an element X
is the first elem...read more
The task is to find the next greater element for each element in a list of integers.
Iterate through the list of integers from right to left.
Use a stack to keep track of elements whose next greater element is yet to be found.
Pop elements from the stack until a greater element is found or the stack is empty.
Assign the next greater element to the current element or -1 if no greater element is found.
Return the list of next greater elements.
Q130. Tell me about recent technologies
Recent technologies include artificial intelligence, blockchain, Internet of Things, and virtual reality.
Artificial intelligence (AI) is being used in various industries for automation and decision-making processes.
Blockchain technology is revolutionizing secure transactions and data storage.
Internet of Things (IoT) connects devices to the internet for remote monitoring and control.
Virtual reality (VR) is creating immersive experiences in gaming, training, and entertainment.
Q131. Minimum Stops for Ninja's Journey Problem Statement
Ninja wishes to travel from his house to a destination X
miles away. He knows there are Y
gas stations along the way, each station i
located at a distance d[i...read more
Calculate the minimum number of refueling stops needed for a ninja to reach a destination with given gas stations and starting fuel.
Iterate through gas stations while maintaining current fuel level and number of stops made
Refuel at each station if necessary to ensure enough fuel to reach the next station or destination
Keep track of the minimum number of stops needed to reach the destination
Q132. Pairwise Sum of Hamming Distance
Given an array ARR
containing N
integers, your task is to calculate the total sum of the Hamming Distance for all possible pairs of elements in the array.
Hamming Distance
The H...read more
Calculate the total sum of Hamming Distance for all possible pairs of elements in an array.
Iterate through all pairs of elements in the array
Calculate the Hamming Distance between each pair of elements
Sum up all the calculated Hamming Distances
Q133. Merge Intervals Problem Statement
You are provided with 'N' intervals, each containing two integers denoting the start time and end time of the interval.
Your task is to merge all overlapping intervals and retu...read more
Merge overlapping intervals and return sorted list of merged intervals by start time.
Iterate through intervals and merge overlapping ones
Sort merged intervals by start time
Return the sorted list of merged intervals
Q134. DFS Traversal Problem Statement
Given an undirected and disconnected graph G(V, E)
, where V
is the number of vertices and E
is the number of edges, the connections between vertices are provided in the 'GRAPH' m...read more
DFS traversal problem on an undirected and disconnected graph to find connected components.
Use Depth First Search (DFS) algorithm to traverse the graph and find connected components.
Maintain a visited array to keep track of visited vertices.
For each unvisited vertex, perform DFS to explore all connected vertices and form a connected component.
Repeat the process until all vertices are visited and print the connected components.
Handle disconnected components by starting DFS fro...read more
Q135. Write a code of Prime number which are printed in the Right angle triangle format.
Code to print prime numbers in right angle triangle format.
Create a function to check if a number is prime or not.
Use nested loops to print the numbers in right angle triangle format.
Start with the first prime number and keep adding prime numbers to the triangle.
Example: 2 3 5 7 11 13 17 19 23 29
Q136. Write a .small C code
A C code that prints out the elements of an array of strings.
Declare an array of strings
Use a loop to iterate through the array
Print out each element
Q137. Joiner transformation Connected and unconnected look u difference
Joiner transformation - connected and unconnected look up difference
Joiner transformation is used to join two sources based on a common key
Connected lookup is used when the lookup table is in the same mapping
Unconnected lookup is used when the lookup table is outside the mapping
Connected lookup returns multiple rows while unconnected lookup returns only one row
Joiner transformation can be used with both connected and unconnected lookup
Q138. Can you tell me about your Google Facilitator Ready program?
Google Facilitator Ready program is a training program that equips individuals with skills to facilitate Google's workshops and events.
The program provides training on how to facilitate Google's workshops and events
Participants learn how to create engaging content and deliver it effectively
The program also covers how to manage logistics and handle participant questions
Upon completion, participants receive a certificate and are eligible to facilitate Google's events
Examples of...read more
Q139. What is the difference between a primary key and a foreign key?
Primary key uniquely identifies a record in a table, while foreign key refers to a field in another table.
Primary key is used to enforce data integrity and ensure uniqueness of records.
Foreign key is used to establish a relationship between two tables.
A table can have only one primary key, but multiple foreign keys.
Example: CustomerID in Orders table is a foreign key that references the Customer table's primary key.
Primary key is denoted by a key symbol, while foreign key is ...read more
Q140. Reverse the String Problem Statement
You are given a string STR
which contains alphabets, numbers, and special characters. Your task is to reverse the string.
Example:
Input:
STR = "abcde"
Output:
"edcba"
Input...read more
Reverse a given string containing alphabets, numbers, and special characters.
Iterate through the string from the end to the beginning and append each character to a new string.
Use built-in functions like reverse() or slicing to reverse the string.
Handle special characters and numbers while reversing the string.
Ensure to consider the constraints provided in the problem statement.
Q141. difference between 8085 and 8086 microprocessor
8086 is an advanced version of 8085 with more features and capabilities.
8086 has a 16-bit data bus while 8085 has an 8-bit data bus.
8086 has more registers than 8085.
8086 has a higher clock speed than 8085.
8086 supports virtual memory while 8085 does not.
8086 has a more advanced instruction set than 8085.
Example: 8086 can perform multiplication and division operations while 8085 cannot.
Q142. Ways To Make Coin Change
Given an infinite supply of coins of varying denominations, determine the total number of ways to make change for a specified value using these coins. If it's not possible to make the c...read more
The task is to find the total number of ways to make change for a specified value using given denominations.
Create a dynamic programming table to store the number of ways to make change for each value up to the target value.
Iterate through each denomination and update the table accordingly.
The final answer will be the value in the table at the target value.
Consider edge cases like when the target value is 0 or when there are no denominations that can make the change.
Example: ...read more
Q143. Paragraph translation from english to tamil.
Translation of a paragraph from English to Tamil
Translate the given paragraph from English to Tamil
Ensure accuracy and maintain the meaning of the original text
Use appropriate grammar and vocabulary
Provide a clear and concise translation
Consider cultural nuances and context if applicable
Q144. What is variable, structure some basic code in that
A variable is a container that holds a value. A structure is a collection of variables of different data types.
Variables are declared with a data type and a name, and can be assigned a value.
Structures are declared using the 'struct' keyword and can contain variables of different data types.
Example code: int age = 25; struct person { char name[20]; int age; float height; };
Variables and structures are fundamental concepts in programming and are used extensively in software de...read more
Q145. Find the 2nd largest number in an array
To find the 2nd largest number in an array of strings, sort the array in descending order and return the second element.
Convert the array of strings to an array of integers for comparison.
Sort the array in descending order.
Return the second element in the sorted array as the 2nd largest number.
Q146. If there are 10 ball 2 red, 5 blue ,3 orange and one ball is picked randomly what is probability that the ball picked is red?
What is the probability of picking a red ball out of 10 balls with 2 red, 5 blue, and 3 orange?
There are 2 red balls out of 10 total balls
The probability of picking a red ball is 2/10 or 1/5
The probability can also be expressed as 20%
Q147. Sort Array Problem Statement
Given an array consisting of 'N' positive integers where each integer is either 0, 1, or 2, your task is to sort the given array in non-decreasing order.
Input:
Each input starts wi...read more
Sort an array of positive integers (0, 1, 2) in non-decreasing order.
Iterate through the array and count the occurrences of 0, 1, and 2.
Update the array with the counts of each element in non-decreasing order.
Print the sorted array for each test case.
Q148. Where do you rate your programming skills on a scale of 1 to 10?
I rate my programming skills at 8 out of 10.
I have experience in multiple programming languages such as Java, Python, and C++.
I have completed several projects including a web application and a mobile app.
I am constantly learning and improving my skills through online courses and personal projects.
Q149. Black Friday Discount Challenge
Imagine it's Black Friday and a supermarket is offering a discount to every 'Nth' customer. You are tasked with calculating bills for customers based on product prices and quanti...read more
The challenge involves calculating bills for customers on Black Friday based on discounts for every 'Nth' customer.
Implement 'blackFriday' function to initialize discount for every Nth customer
Implement 'generateBill' function to calculate total bill for each customer's purchase
Consider input constraints and generate final bill amounts for each customer in each test case
Q150. Sum of Digits Problem Statement
Given an integer 'N', continue summing its digits until the result is a single-digit number. Your task is to determine the final value of 'N' after applying this operation iterat...read more
Given an integer 'N', find the final single-digit value by summing its digits iteratively.
Iteratively sum the digits of the given integer until the result is a single-digit number
Output the final single-digit integer for each test case
Follow the constraints provided in the problem statement
Q151. Binary Palindrome Check
Given an integer N
, determine whether its binary representation is a palindrome.
Input:
The first line contains an integer 'T' representing the number of test cases.
The next 'T' lines e...read more
Implement a function to determine if the binary representation of a given integer is a palindrome.
Convert the integer to binary representation
Check if the binary representation is a palindrome by comparing it with its reverse
Return true if it is a palindrome, false otherwise
Q152. Do you know 4 pillars of OOP? Explain.
The 4 pillars of OOP are Abstraction, Encapsulation, Inheritance, and Polymorphism.
Abstraction: Hiding implementation details and showing only necessary information.
Encapsulation: Binding data and functions together to prevent external interference.
Inheritance: Creating new classes from existing ones, inheriting properties and methods.
Polymorphism: Using a single interface to represent multiple types of objects.
Q153. Ninja and His Secret Information Encoding Problem
Ninja, a new member of the FBI, has acquired some 'SECRET_INFORMATION' that he needs to share with his team. To ensure security against hackers, Ninja decides t...read more
The task is to determine if the encoding and decoding process of 'SECRET_INFORMATION' is successful.
Read the number of test cases 'T'
For each test case, encode the 'SECRET_INFORMATION' and then decode it
Compare the decoded string with the original 'SECRET_INFORMATION'
Print 'Transmission successful' if they match, else print 'Transmission failed'
Q154. Bottom View of Binary Tree
Given a binary tree, determine and return its bottom view when viewed from left to right. Assume that each child of a node is positioned at a 45-degree angle from its parent.
Nodes in...read more
Given a binary tree, determine and return its bottom view when viewed from left to right.
Traverse the binary tree level by level and keep track of the horizontal distance and depth of each node
For each horizontal distance, keep track of the node with the maximum depth
Return the nodes in the bottom view from left to right
Q155. What are the latest technologies you have heard of?
The latest technologies include AI, blockchain, 5G, quantum computing, and IoT.
AI - machine learning, natural language processing
Blockchain - decentralized ledgers, smart contracts
5G - faster internet speeds, low latency
Quantum computing - exponential processing power
IoT - interconnected devices, data collection
Q156. 1.Write a validation rule to bypass it for particular profile. 2.Write a trigger to update contact record upon account update. Write a soql query to fetch the contact records which do not have account.
Answering Salesforce Marketing Cloud Developer interview questions
To bypass validation rule for a particular profile, use the $Profile global variable in the rule formula
To update contact record upon account update, write a trigger on Account object and update related Contact records
To fetch contact records without account, use SOQL query with LEFT JOIN on Account object and WHERE clause to filter null values
Q157. What is the difference between instance and local variable?
Instance variables are declared in a class and can be accessed by any method in the class. Local variables are declared in a method and can only be accessed within that method.
Instance variables are declared at the class level, while local variables are declared within a method.
Instance variables can be accessed by any method in the class, while local variables can only be accessed within the method they are declared in.
Instance variables are initialized to default values, wh...read more
Q158. What are the four Pillars of OOPS?
The four pillars of OOPS are Abstraction, Encapsulation, Inheritance, and Polymorphism.
Abstraction: Hiding implementation details and showing only necessary information.
Encapsulation: Binding data and functions together and restricting access to them.
Inheritance: Creating new classes from existing ones, inheriting properties and methods.
Polymorphism: Ability of objects to take on multiple forms or behaviors.
Q159. Statements P: Some mobiles are cameras. Q: Some cameras are calculators. Conclusions I. All calculators are mobiles. II. All cameras are mobiles
The conclusions cannot be determined from the given statements.
Statement P and Q do not have a direct relationship.
There is no information given about the relationship between calculators and cameras.
Therefore, neither conclusion can be drawn.
Q160. Sort the array and write a code for searching array element
Sort and search an array in software engineering interview
Use built-in sorting functions or implement your own sorting algorithm
For searching, use linear search or binary search depending on the size of the array
Consider the time complexity of the sorting and searching algorithms
Ensure the code is efficient and handles edge cases properly
Q161. How spring boot works , what is beans and scope of the beans
Spring Boot is a framework that simplifies the development of Java applications by providing pre-configured settings and dependencies.
Spring Boot uses the concept of 'beans' to manage application components and their dependencies.
Beans are Java objects that are instantiated, assembled, and managed by the Spring IoC container.
The scope of a bean determines its lifecycle and visibility within the application context.
There are several bean scopes in Spring Boot, including single...read more
Q162. LRU Cache Task Description
Design and implement a data structure for a Least Recently Used (LRU) cache to support two operations:
get(key)
- Returns the value for the given key if it exists in the cache, other...read more
Design and implement a Least Recently Used (LRU) cache data structure supporting get and put operations with specified constraints.
Implement a data structure for LRU cache with get and put operations
Maintain a capacity limit and remove least recently used item when exceeding capacity
Handle get operation by returning value for given key or -1 if key does not exist
Handle put operation by inserting or updating key-value pair in cache
Ensure time complexity is optimized for effici...read more
Q163. Left View of a Binary Tree Problem Statement
Given a binary tree, your task is to print the left view of the tree.
Example:
Input:
The input will be in level order form, with node values separated by a space. U...read more
Print the left view of a binary tree given in level order form.
Traverse the tree level by level and print the first node of each level
Use a queue to keep track of nodes at each level
Handle null nodes by using a placeholder value like -1
Q164. What are the different data types in python?
Python has several built-in data types including numeric, sequence, and mapping types.
Numeric types include integers, floats, and complex numbers.
Sequence types include lists, tuples, and strings.
Mapping types include dictionaries.
Boolean type is also available.
Type() function can be used to determine the data type of a variable.
Q165. what is the difference between while and do while?
while loop checks condition before executing, do while loop executes at least once before checking condition.
while loop is entry controlled loop, do while loop is exit controlled loop
while loop may not execute at all if condition is false initially, do while loop executes at least once
while loop syntax: while(condition){ //code to execute }
do while loop syntax: do{ //code to execute }while(condition);
Q166. Subarray Sums I Problem Statement
You are provided with an array of positive integers ARR
that represents the strengths of different “jutsus” (ninja techniques). You are also given the strength of the enemy S
, ...read more
Count the number of subarrays whose combined strength matches the given enemy strength.
Iterate through the array and maintain a running sum to check for subarrays with sum equal to the enemy strength.
Use a hashmap to store the running sum frequencies and increment the count of subarrays accordingly.
Return the count of subarrays that sum up to the given enemy strength.
Q167. Merge Sort Problem Statement
You are given a sequence of numbers, ARR
. Your task is to return a sorted sequence of ARR
in non-descending order using the Merge Sort algorithm.
Explanation:
The Merge Sort algorit...read more
Implement Merge Sort algorithm to sort a sequence of numbers in non-descending order.
Understand the Merge Sort algorithm which involves dividing the array into two halves, sorting each half, and then merging them back together.
Recursively apply the Merge Sort algorithm until the base case of having a single element in the array is reached.
Merge the sorted halves back together in a way that maintains the non-descending order of the elements.
Ensure to handle the input constrain...read more
Q168. Statements P: Some bags are hot. Q: All hots are cakes. Conclusions I. All cakes are bags. II. Some bags are cakes.
Conclusion II follows from the given statements.
Statement P and Q do not provide enough information to conclude that all cakes are bags.
However, it can be concluded that some bags are cakes as some bags are hot and all hots are cakes.
Therefore, Conclusion II is true while Conclusion I is false.
Q169. What is the difference between C and C++?
C++ is an extension of C with object-oriented programming features.
C++ supports classes and objects while C does not.
C++ has better support for polymorphism and inheritance.
C++ has a standard template library (STL) for data structures and algorithms.
C++ allows function overloading and default arguments.
C++ has exception handling for error management.
C++ is more complex and has a steeper learning curve than C.
Q170. Which programming languages you're comfortable with ?
Q171. Which is the most comfortable programming language for you?
Python is the most comfortable programming language for me.
Python has a simple and easy-to-learn syntax.
It has a vast collection of libraries and frameworks.
Python is versatile and can be used for various applications such as web development, data analysis, and machine learning.
Python has a large community that provides support and resources.
Examples: Flask, Django, NumPy, Pandas, TensorFlow.
Q172. what is the difference between java 7 and java 8
Java 8 introduced new features like lambda expressions, streams, and default methods compared to Java 7.
Java 8 introduced lambda expressions for functional programming.
Java 8 added streams API for processing collections in a functional style.
Java 8 introduced default methods in interfaces to allow adding new methods to interfaces without breaking existing implementations.
Java 8 included the new Date and Time API (java.time) to address the shortcomings of the old java.util.Dat...read more
Q173. skeleton of html , what is variables?
Variables in HTML are used to store and manipulate data within a web page.
Variables in HTML are typically used in conjunction with JavaScript to store and manipulate data.
They are declared using the 'var' keyword.
Variables can store various types of data such as strings, numbers, and booleans.
Example: var name = 'John';
Q174. How will you print the address of a variable without using a pointer?
Printing the address of a variable without using a pointer can be done by using the & operator.
Use the & operator before the variable name to print its address
Example: int num = 10; printf("%p", &num);
This will print the address of the variable num
Q175. Simple SQL query to find duplicate items in a database.
SQL query to find duplicate items in a database.
Use GROUP BY clause to group the items by their values
Use HAVING clause to filter out groups with count greater than 1
Select the columns you want to display in the result
Q176. Write a program for reverse string?
A program to reverse a given string.
Create an empty string to store the reversed string
Loop through the original string from the end to the beginning
Add each character to the new string
Return the new string
Q177. What is design patterns in java
Design patterns are reusable solutions to common software problems in Java.
Design patterns provide a standard way to solve common problems in software development.
They help in creating flexible, reusable, and maintainable code.
Examples of design patterns include Singleton, Factory, Observer, and Decorator.
Design patterns can be categorized into three types: creational, structural, and behavioral.
Q178. draw pin diagram of 8085 microprocessor
Pin diagram of 8085 microprocessor
8085 has 40 pins in total
Pins are grouped into 5 categories: power supply, address bus, data bus, control and status signals
Pin 1 is the reset pin, Pin 40 is the Vcc pin
Examples of control signals: RD, WR, ALE, INT, HOLD
Examples of status signals: S0, S1, IO/M, HLDA
Q179. what is opamp?
Opamp stands for operational amplifier. It is an electronic device used to amplify and process signals.
Opamps have high gain and can amplify signals to a very high degree.
They are commonly used in audio amplifiers, filters, and signal processing circuits.
Opamps have two input terminals and one output terminal.
They can be configured in different ways to perform various functions such as amplification, filtering, and oscillation.
Examples of opamps include LM741, LM358, and TL08...read more
Q180. what is c,c++,difference between c and c++
C and C++ are programming languages. C++ is an extension of C with additional features.
C is a procedural language while C++ is an object-oriented language.
C++ supports features like classes, inheritance, and polymorphism which are not present in C.
C++ also has better support for templates and exception handling compared to C.
C++ code can also be written in a more modular and reusable way compared to C.
C++ is often used for developing complex software systems like operating sy...read more
Q181. Write a code to print first 10 element of Fibonacci series.
Code to print first 10 elements of Fibonacci series.
Declare variables for first two numbers of the series
Use a loop to generate the next numbers in the series
Print the first 10 numbers of the series
Q182. Why does Java have no pointers?
Java has no pointers for safety reasons and to simplify memory management.
Java uses references instead of pointers to avoid security vulnerabilities.
Pointers can cause memory leaks and dangling references, which Java avoids.
Java's garbage collector automatically manages memory, making pointers unnecessary.
Example: Java's NullPointerException is a result of using a null reference, not a pointer.
Example: C++ allows pointer arithmetic, which can lead to buffer overflows and othe...read more
Q183. Explain about Design Patterns
Design patterns are reusable solutions to common software development problems.
Design patterns provide a common language for developers to communicate about solutions.
They can improve code quality, maintainability, and scalability.
Examples include the Singleton, Factory, and Observer patterns.
Design patterns can be categorized into creational, structural, and behavioral patterns.
Q184. Explain about Request Delegate
Request Delegate is a middleware component in ASP.NET Core pipeline.
Request Delegate is responsible for handling HTTP requests and generating HTTP responses.
It is a function that takes an HttpContext object as input and returns a Task.
It can be used to modify the request or response, or to pass the request to the next middleware component in the pipeline.
Example: app.Use(async (context, next) => { await next(); });
Q185. What is stack?
A stack is a data structure that follows the Last In First Out (LIFO) principle.
Elements are added to the top of the stack and removed from the top.
Common operations include push (add element) and pop (remove element).
Stacks are used in programming for function calls, expression evaluation, and memory management.
Q186. What do you know about maps, tell me something about maps?
Maps are visual representations of geographical areas, providing information about the location, terrain, and features of a specific area.
Maps are used to navigate and understand the world around us.
They can show political boundaries, roads, rivers, mountains, and other physical features.
Maps can be used for various purposes such as planning routes, analyzing data, and studying geography.
Different types of maps include topographic maps, road maps, weather maps, and thematic m...read more
Q187. What approach did you take to learn data science?
I took a structured approach to learn data science.
Started with learning the basics of statistics and programming
Took online courses and read books on data science
Practiced on real-world datasets and participated in Kaggle competitions
Joined a data science community to learn from others and share knowledge
Continuously updated my skills and knowledge through online resources and attending conferences
Q188. Explain the term inheritance?
Inheritance is a mechanism in object-oriented programming where a new class is created by inheriting properties of an existing class.
Inheritance allows code reusability and saves time and effort in writing new code.
The existing class is called the parent or base class, and the new class is called the child or derived class.
The child class inherits all the properties and methods of the parent class and can also add its own unique properties and methods.
For example, a class 'An...read more
Q189. 1 : What is the time if it's 360°from 12Pm To 3Pm 2 : Time Distance to travel 300 kilometres with a speed of 100 3 : which colour Do we get if mixed yello , red , green
1. 3 hours 2. 3 hours 3. Brown
1. To go from 12PM to 3PM, it takes 3 hours as it is a 360° rotation on a clock.
2. To travel 300 km at a speed of 100 km/h, it takes 3 hours.
3. Mixing yellow, red, and green typically results in the color brown.
Q190. List out the differences between Generalization and Specialization in DBMS
Generalization and Specialization are two important concepts in DBMS.
Generalization is the process of combining two or more entities into a higher-level entity.
Specialization is the process of dividing a higher-level entity into two or more lower-level entities.
Generalization is a top-down approach while specialization is a bottom-up approach.
Generalization is used to represent a group of entities that share common attributes and relationships.
Specialization is used to repres...read more
Q191. What exactly is index hunting, and how does it aid query performance?
Index hunting is the process of finding the best index for a query to improve its performance.
Index hunting involves analyzing the query and the database schema to determine the most efficient index to use.
It can involve creating new indexes or modifying existing ones.
For example, if a query frequently searches for a specific column, creating an index on that column can significantly improve performance.
Index hunting is an important part of database optimization and can great...read more
Q192. What is an array?
An array is a collection of elements of the same data type, stored in contiguous memory locations.
Arrays can be one-dimensional or multi-dimensional
Elements in an array can be accessed using their index
Arrays can be initialized with values at declaration
Examples: int[] numbers = {1, 2, 3}; char[] letters = {'a', 'b', 'c'};
Arrays have a fixed size once declared
Q193. Exception handling in Java. Try catch finally. Types of Exceptions ans etc.
Exception handling in Java involves using try-catch-finally blocks to handle and manage exceptions.
Java provides a mechanism to handle runtime errors called exceptions.
The try block is used to enclose the code that might throw an exception.
The catch block is used to catch and handle the exception.
The finally block is used to execute code regardless of whether an exception occurred or not.
There are two types of exceptions: checked exceptions and unchecked exceptions.
Checked ex...read more
Q194. Why java is platform independent?
Java is platform independent because it uses the concept of bytecode and virtual machine.
Java programs are 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.
The JVM interprets the bytecode and translates it into machine code that can be understood by the underlying operating system.
This allows Java programs to run on any platform that has a comp...read more
Q195. Explain data type in c?
Data type in C refers to the type of data that a variable can hold.
C has basic data types like int, float, char, double, etc.
Derived data types like arrays, pointers, structures, and unions can also be created.
Each data type has a specific range of values that it can hold.
Data types can be modified using type qualifiers like const, volatile, etc.
Q196. write a coding for given year is leap or not
Coding to check if a given year is leap or not
A year is a leap year if it is divisible by 4 but not by 100, or if it is divisible by 400
Use modulo operator to check if the year is divisible by 4, 100, and 400
Return true if the year is divisible by 4 and not by 100, or if it is divisible by 400. Else, return false
Q197. What are the basics concepts of Oops and explain them ?
Object-oriented programming concepts include encapsulation, inheritance, and polymorphism.
Encapsulation: Bundling data and methods together in a class to hide implementation details.
Inheritance: Creating new classes from existing ones, inheriting their properties and behaviors.
Polymorphism: Objects of different classes can be treated as objects of a common superclass.
Example: Encapsulation - A class 'Car' with private variables like 'speed' and public methods like 'accelerate...read more
Q198. What are the bounding methods in React? Difference between Class Component and Functional Component in ReactJS?
Bounding methods in React are used to limit the scope of a component's updates.
Bounding methods include shouldComponentUpdate, getSnapshotBeforeUpdate, and componentDidUpdate.
shouldComponentUpdate allows a component to decide if it should update based on changes in props or state.
getSnapshotBeforeUpdate allows a component to capture information before a change is made to the DOM.
componentDidUpdate is called after a component updates and can be used to perform additional actio...read more
Q199. code to remove duplicate entries in a string
Code to remove duplicate entries in a string
Create an empty array to store unique strings
Iterate through each string in the input array
Check if the string is already in the unique array, if not add it
Q200. What is constructor overloading?
Constructor overloading is the ability to have multiple constructors with different parameters in a class.
Constructor overloading allows creating objects with different initializations.
It helps in providing flexibility and convenience to the users of the class.
Constructors can be overloaded by changing the number, type, or order of parameters.
Example: class Person { Person() {} Person(String name) {} }
More about working at Cognizant
Top HR Questions asked in JBF RAK LLC
Interview Process at JBF RAK LLC
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month