Capgemini
100+ Hindustan Petroleum Interview Questions and Answers
Q1. Split Array with Equal Sums Problem Statement
Given an array 'ARR' of size 'N', determine if there exists a triplet (i, j, k) satisfying the conditions: 0 < i , i + 1 < j , j + 1 < k and k < N - 1, such that th...read more
Q2. Reverse Linked List Problem Statement
Given a singly linked list of integers, return the head of the reversed linked list.
Example:
Initial linked list: 1 -> 2 -> 3 -> 4 -> NULL
Reversed linked list: 4 -> 3 -> 2...read more
Q3. Factorial Calculation Problem Statement
Develop a program to compute the factorial of a given integer 'n'.
The factorial of a non-negative integer 'n', denoted as n!
, is the product of all positive integers les...read more
Q4. Find the Duplicate Number Problem Statement
Given an integer array 'ARR' of size 'N' containing numbers from 0 to (N - 2). Each number appears at least once, and there is one number that appears twice. Your tas...read more
Q5. 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
Q6. Wildcard Pattern Matching Problem Statement
Implement a wildcard pattern matching algorithm to determine if a given wildcard pattern matches a text string completely.
The wildcard pattern may include the charac...read more
Q7. Subarray With Given Sum Problem Statement
Given an array ARR
of N integers and an integer S, determine if there exists a contiguous subarray within the array with a sum equal to S. If such a subarray exists, re...read more
Q8. Minimum Operations to Make Strings Equal
Given two strings A
and B
consisting of lowercase English letters, determine the minimum number of pre-processing moves required on string A
to make it equal to string B...read more
Q9. The Skyline Problem
Compute the skyline of given rectangular buildings in a 2D city, eliminating hidden lines and forming the outer contour of the silhouette when viewed from a distance. Each building is descri...read more
Q10. Time to Burn Tree Problem
You are given a binary tree consisting of 'N' unique nodes and a start node where the burning will commence. The task is to calculate the time in minutes required to completely burn th...read more
Q11. 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
Q12. Circular Move Problem Statement
You have a robot currently positioned at the origin (0, 0) on a two-dimensional grid, facing the north direction. You are given a sequence of moves in the form of a string of len...read more
Q13. 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
Q14. Kth Largest Number Problem Statement
Design a data structure to handle a stream of numbers dynamically and efficiently find the kth largest number at any given moment.
Explanation:
You will be presented with a ...read more
Q15. Next Greater Number Problem Statement
Given a string S
which represents a number, determine the smallest number strictly greater than the original number composed of the same digits. Each digit's frequency from...read more
Q16. What is the advantage of generic collection, when and why we should approach for that?
Generic collections provide type safety and reusability in software development.
Generic collections allow us to store and manipulate objects of any type in a type-safe manner.
They provide compile-time type checking, reducing the chances of runtime errors.
They promote code reusability by allowing the same collection to be used with different types.
Generic collections improve performance by eliminating the need for boxing and unboxing operations.
They enable us to write cleaner ...read more
Q17. what is array and how it is different from linked lists?
Array is a collection of elements of same data type. Linked list is a data structure where each element points to the next one.
Arrays have fixed size, linked lists can grow dynamically
Accessing elements in an array is faster than in a linked list
Inserting or deleting elements in a linked list is faster than in an array
Arrays are stored in contiguous memory locations, linked lists are not
Arrays are used for random access, linked lists are used for sequential access
Q18. What is the difference between one way SSL and two way SSL?
One way SSL is unidirectional while two way SSL is bidirectional.
One way SSL only authenticates the server to the client while two way SSL authenticates both the server and the client to each other.
One way SSL uses only server certificate while two way SSL uses both server and client certificates.
One way SSL is commonly used in websites while two way SSL is used in applications that require higher security such as online banking.
One way SSL is vulnerable to man-in-the-middle ...read more
Q19. What is multi thread,diff bwtn class and interface,what is abstract,what is constractor,compliler,jdk,oops concept,2Aptitude question,what is ur strenght,hobby.
Interview question for Software Developer covering topics like multi-threading, class vs interface, abstract, constructor, compiler, JDK, OOPs concepts, aptitude, strengths, and hobbies.
Multi-threading allows for concurrent execution of code
Classes are blueprints for objects while interfaces define a set of methods that a class must implement
Abstract classes cannot be instantiated and are meant to be extended by subclasses
Constructors are special methods used to initialize ob...read more
Q20. 1)What is oops? 2)difference between method overloading and method overriding? 3)what is static?
Answers to common questions asked in a software developer interview.
OOPs stands for Object-Oriented Programming which is a programming paradigm based on the concept of objects.
Method overloading is when multiple methods have the same name but different parameters, while method overriding is when a subclass provides its own implementation of a method that is already present in its parent class.
Static is a keyword used to create variables and methods that belong to a class rath...read more
Q21. How the login page comes when clicks on some webpage icon like facebook?
The login page is displayed when a user clicks on a webpage icon like Facebook by redirecting to a separate login page.
Clicking on the webpage icon triggers a redirect to the login page
The login page prompts the user to enter their credentials
After successful login, the user is redirected back to the original webpage
Q22. What is the difference between Soap and Rest?
SOAP is a protocol while REST is an architectural style for web services.
SOAP uses XML for messaging while REST uses JSON or XML.
SOAP requires more bandwidth and processing power than REST.
SOAP has built-in error handling while REST relies on HTTP error codes.
SOAP supports both stateful and stateless communication while REST is stateless.
SOAP is commonly used in enterprise applications while REST is used for web-based applications.
Example of SOAP: Web Services Description Lan...read more
Q23. difference between string , string buffer
String is immutable, String Buffer is mutable
String is immutable, meaning its value cannot be changed once it is created
String Buffer is mutable, meaning its value can be changed after it is created
String is faster and more memory efficient than String Buffer
String Buffer is synchronized, making it thread-safe for multiple operations
Q24. How is public key different than private key?
Public key is used for encryption and private key is used for decryption.
Public key is shared with others to encrypt messages.
Private key is kept secret and used to decrypt messages.
Public key is used in digital signatures to verify authenticity.
Examples include RSA, DSA, and Elliptic Curve Cryptography.
Public key is longer than private key for added security.
Q25. How is public cloud different than private cloud?
Public cloud is accessible to everyone while private cloud is restricted to a specific organization.
Public cloud is owned and operated by third-party providers while private cloud is owned and operated by the organization itself.
Public cloud is accessible over the internet while private cloud is accessible only within the organization's network.
Public cloud is more cost-effective for small businesses while private cloud is more secure for large enterprises.
Examples of public ...read more
Q26. What are the important categaries of software?
The important categories of software are system software, application software, and programming software.
System software: manages computer hardware and provides common services for other software. Examples: operating systems, device drivers, firmware.
Application software: performs specific tasks for end-users. Examples: word processors, web browsers, video games.
Programming software: provides tools for software developers to create, debug, and maintain software. Examples: com...read more
Q27. 1.input ="india" required output="nda"(removing duplicate i) using JAVA8 2.find second high number from array ={10,20,30,25} => output =25 Using java8
1. Remove duplicate 'i' from input string 'india' using Java8. 2. Find second highest number from array {10,20,30,25} using Java8.
For the first question, you can use Java8 streams to filter out the duplicate 'i' from the input string.
For the second question, you can use Java8 streams to sort the array in descending order and then get the second element.
Q28. Why do you use two mobile numbers
To separate personal and professional calls, and to ensure availability and accessibility.
Separate personal and professional calls
Ensure availability and accessibility
Maintain work-life balance
Avoid mixing personal and work-related contacts
Q29. Write a program in JavaScript for checking if someone is 18 years old or more, or if they are less than 18.
Program in JavaScript to check if someone is 18 years old or more.
Create a function that takes an age as input
Use an if statement to check if the age is greater than or equal to 18
Return 'You are 18 or older' if true, otherwise return 'You are under 18'
Q30. How do we configure SSL at HTTP layer?
SSL can be configured at HTTP layer by enabling HTTPS protocol and configuring SSL certificates.
Enable HTTPS protocol in web server configuration
Generate or obtain SSL certificates
Configure SSL certificates in web server
Ensure secure communication between client and server
Test SSL configuration for any vulnerabilities
Q31. What is Class ? How You Will Use them in Coding
A class is a blueprint for creating objects in object-oriented programming. It defines the properties and behaviors of objects.
Classes are used to create objects with specific attributes and methods.
They help in organizing code by grouping related data and functions together.
Inheritance allows classes to inherit properties and methods from other classes.
Encapsulation ensures that data is kept private within a class.
Polymorphism allows objects of different classes to be treate...read more
Q32. 1.In and array of string give me the string with longest length
The answer to the question is the string with the longest length in an array of strings.
Iterate through the array of strings and keep track of the string with the longest length.
Compare the length of each string with the current longest string and update it if necessary.
Return the string with the longest length.
Q33. What are the methods supported by REST?
REST supports methods like GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD.
GET - retrieves a resource
POST - creates a new resource
PUT - updates an existing resource
DELETE - deletes a resource
PATCH - partially updates a resource
OPTIONS - returns the supported methods for a resource
HEAD - returns metadata about a resource
Q34. What do you understand by Cloud?
Cloud refers to the delivery of computing services over the internet.
Cloud computing allows users to access data and applications from anywhere with an internet connection.
It offers scalability, flexibility, and cost-effectiveness compared to traditional on-premises computing.
Examples of cloud services include Amazon Web Services, Microsoft Azure, and Google Cloud Platform.
Q35. How to use multiple dispatch in redux?
Multiple dispatch is not a feature of Redux. It can be achieved using middleware or custom logic.
Middleware like redux-thunk or redux-saga can be used to dispatch multiple actions based on a single action.
Custom logic can be implemented in the reducer to handle multiple actions based on a single action type.
For example, a single 'ADD_ITEM' action can trigger multiple actions like 'UPDATE_TOTAL', 'UPDATE_HISTORY', etc.
Multiple dispatch can also be achieved using the 'redux-bat...read more
Q36. 1. Introduce yourself 2. How to fetch 50% record from table using SQL query
To fetch 50% records from a table using SQL query
Use the LIMIT clause to specify the number of records to return
Calculate 50% of the total records in the table to determine the limit value
Order the records in a specific way if needed before applying the LIMIT clause
Q37. What features of the tool you have worked on?
I have worked on a tool that includes features such as real-time collaboration, version control, and automated testing.
Real-time collaboration allows multiple users to work on the same project simultaneously.
Version control helps track changes made to the code and allows for easy rollback to previous versions.
Automated testing ensures that code changes do not introduce new bugs or issues.
Q38. What is the difference between string and string builder? Advantages of mvc?
String is immutable while StringBuilder is mutable. MVC provides separation of concerns and promotes code reusability.
String is a sequence of characters that cannot be modified once created.
StringBuilder is a mutable sequence of characters that can be modified without creating a new object.
Advantages of MVC include separation of concerns, code reusability, and easier maintenance.
MVC separates the application into three components: Model, View, and Controller.
Example: String s...read more
Q39. What is Interface, Why use them
An interface is a contract that specifies the methods that a class must implement. They are used to achieve abstraction and polymorphism.
Interfaces allow for loose coupling between classes
They provide a way to achieve multiple inheritance in Java
They are used to achieve abstraction and polymorphism
Interfaces are used to define a set of methods that a class must implement
They are commonly used in Java to define APIs
Q40. Write a program for circular link list. How toggle a bit reverse a string
Program for circular linked list, toggling a bit, and reversing a string.
Create a struct for node with data and next pointer for circular linked list
Implement functions to insert, delete, and display nodes in circular linked list
To toggle a bit, use XOR operator with 1
To reverse a string, use two pointers approach swapping characters from start and end
Q41. difference between list and tuple
List is mutable, tuple is immutable in Python.
List can be modified after creation, tuple cannot.
List uses square brackets [], tuple uses parentheses ().
List is used for collections of items that may change, tuple for fixed collections.
Example: list - [1, 2, 3], tuple - (1, 2, 3)
Q42. how to optimize the Db queries?
Optimizing Db queries involves using indexes, minimizing data retrieval, and avoiding unnecessary joins.
Use indexes on columns frequently used in WHERE clauses
Minimize data retrieval by selecting only necessary columns
Avoid unnecessary joins by denormalizing data when possible
Use query optimization tools like EXPLAIN in MySQL to analyze query performance
Q43. Give me an example of OAuth 2.0 in practical life?
OAuth 2.0 is used for secure authorization and authentication in various applications.
OAuth 2.0 is used by Google to allow third-party applications to access user data without sharing passwords.
It is used by Facebook to allow users to log in to other websites using their Facebook credentials.
It is used by Microsoft to allow users to grant access to their Office 365 data to third-party applications.
OAuth 2.0 is also used in mobile applications to authenticate users and access ...read more
Q44. @Springbootapplicaton, Difference between @RestController and @Controller
In Spring Boot, @RestController is used for RESTful web services while @Controller is used for MVC applications.
RestController is used for RESTful web services, returning data directly in the response body
Controller is used for traditional MVC applications, returning a view
RestController is a specialized version of @Controller with @ResponseBody annotation
Example: @RestController is used for APIs that return JSON data, while @Controller is used for rendering HTML pages
Q45. What is Multithreading Deep copy shallow copy Merge two dictionaries
Multithreading is the ability of a CPU to execute multiple threads concurrently. Deep copy creates a new object with copies of the original object's data, while shallow copy creates a new object that references the original object's data. Merging two dictionaries combines the key-value pairs of two dictionaries into one.
Multithreading allows for concurrent execution of multiple threads on a CPU.
Deep copy creates a new object with copies of the original object's data, ensuring...read more
Q46. what do you mean by Oops concepts
Oops concepts refer to Object-Oriented Programming principles like Inheritance, Encapsulation, Polymorphism, and Abstraction.
Inheritance allows a class to inherit properties and behavior from another class.
Encapsulation involves bundling data and methods that operate on the data into a single unit.
Polymorphism allows objects to be treated as instances of their parent class.
Abstraction hides the complex implementation details and only shows the necessary features to the outsid...read more
Q47. Thread implementation, difference between collection and collections
Thread implementation is a way to achieve multitasking in a program. Collection is an interface while Collections is a utility class in Java.
Thread implementation allows for concurrent execution in a program.
Collection is an interface in Java that represents a group of objects, while Collections is a utility class that provides static methods for operating on collections.
Example: List is a Collection interface, and Collections class provides methods like sort() and reverse() ...read more
Q48. What is Object and Encapsulation ?
Object is a collection of data and methods, while encapsulation is the concept of bundling data and methods within a single unit.
Object is an instance of a class that encapsulates data and behavior.
Encapsulation hides the internal state of an object and only allows access through methods.
Encapsulation helps in achieving data hiding, abstraction, and modularity.
Example: A car object can have data like color and speed, and methods like accelerate and brake.
Example: Encapsulatio...read more
Q49. What input files you have worked on?
I have worked on various input files including CSV, JSON, XML, and text files.
CSV files - Used for tabular data such as Excel spreadsheets.
JSON files - Used for storing and exchanging data.
XML files - Used for defining document structure and data.
Text files - Used for storing plain text data.
Q50. 1.In an array give me number closest to 100
Find the number closest to 100 in an array.
Iterate through the array and calculate the absolute difference between each number and 100.
Keep track of the minimum difference and the corresponding number.
Return the number with the minimum difference.
Q51. Write a code to call method from interface
Code to call a method from an interface
Create a class that implements the interface
Override the method in the class
Create an object of the class and assign it to the interface type
Call the method using the interface reference
Q52. what are idempotent http methods?
Idempotent HTTP methods are methods that can be called multiple times without different outcomes.
Idempotent methods do not have side effects on the server.
GET, PUT, and DELETE are examples of idempotent HTTP methods.
Idempotent methods are safe to retry in case of network failures.
Q53. Finding the Missing number in the program
Use XOR operation to find the missing number in an array of integers.
Iterate through the array and XOR all the elements with their indices.
Then XOR the result with the indices from 0 to n.
The final result will be the missing number.
Q54. What exception will occur in pl/,sql
Various exceptions can occur in PL/SQL, such as NO_DATA_FOUND, TOO_MANY_ROWS, and INVALID_CURSOR.
NO_DATA_FOUND exception is raised when a SELECT INTO statement returns no rows.
TOO_MANY_ROWS exception is raised when a SELECT INTO statement returns multiple rows.
INVALID_CURSOR exception is raised when an invalid cursor operation is performed.
Q55. For designing what tool you are using
I use various design tools such as Adobe XD, Sketch, Figma, and InVision for designing user interfaces.
Adobe XD
Sketch
Figma
InVision
Q56. What is the meaning of Salesforce
Salesforce is a cloud-based customer relationship management (CRM) platform that helps businesses manage their sales, customer service, marketing, and more.
Salesforce is a leading CRM software used by businesses to manage customer relationships and sales processes.
It provides a centralized platform for storing customer data, tracking interactions, and automating sales and marketing tasks.
Salesforce offers a range of tools and features, including sales forecasting, lead manage...read more
Q57. Tell me ES6 Features in javascript
ES6 features in JavaScript include arrow functions, classes, template literals, destructuring, and more.
Arrow functions provide a more concise syntax for writing functions.
Classes allow for easier object-oriented programming in JavaScript.
Template literals enable easier string interpolation and multiline strings.
Destructuring allows for easily extracting values from arrays or objects.
Let and const provide block-scoped variables, replacing var.
Q58. How to debug code basic oops concepts
Debugging code with basic OOPs concepts involves identifying and fixing errors in object-oriented programming code.
Identify the specific error or bug in the code by using debugging tools like breakpoints and print statements.
Check for common OOPs concepts like inheritance, encapsulation, polymorphism, and abstraction to ensure they are implemented correctly.
Use object-oriented design principles to refactor code for better organization and readability.
Test the code thoroughly ...read more
Q59. Difference between Future & Completable Future
Completable Future is an extension of Future in Java, providing more flexibility and control over asynchronous computations.
Completable Future can be manually completed or cancelled, while Future cannot.
Completable Future supports chaining of multiple asynchronous operations.
Completable Future allows handling exceptions using exceptionally() method.
Completable Future provides methods like thenApply(), thenAccept(), thenCombine() for composing asynchronous computations.
Q60. 4)what is java& feature of java?
Java is a popular programming language known for its portability and security features.
Java is an object-oriented language
It is platform-independent and can run on any device with a JVM
Java has automatic memory management through garbage collection
It has strong security features such as sandboxing and encryption
Java has a vast library of pre-built classes and APIs
Examples of Java-based applications include Android apps, enterprise software, and web applications
Q61. OSI model (Networking)?
The OSI model is a conceptual model that describes the communication functions of a telecommunication or computing system.
The OSI model has 7 layers: Physical, Data Link, Network, Transport, Session, Presentation, and Application.
Each layer has a specific function and communicates with the layers above and below it.
The Physical layer deals with the physical transmission of data, while the Application layer deals with user interfaces and applications.
Examples of protocols that...read more
Q62. What is Abstract Class
Abstract class is a class that cannot be instantiated and is used as a base class for other classes.
An abstract class can have abstract and non-abstract methods.
Abstract methods have no implementation and must be implemented by the derived class.
An abstract class can have constructors and fields.
An abstract class can be used to define a common interface for a group of related classes.
Example: Animal is an abstract class and Dog, Cat, and Bird are derived classes that inherit ...read more
Q63. Write an ordered list & unordered list in HTML.
HTML ordered and unordered list example
Use <ol> tag for ordered list
Use <ul> tag for unordered list
Use <li> tag for each list item
Example: <ol><li>Item 1</li><li>Item 2</li></ol>
Example: <ul><li>Item A</li><li>Item B</li></ul>
Q64. Explain Oops Concept?
OOPs is a programming paradigm based on the concept of objects, which can contain data and code.
OOPs stands for Object-Oriented Programming.
It focuses on creating objects that interact with each other to solve a problem.
It has four main concepts: Encapsulation, Inheritance, Polymorphism, and Abstraction.
Encapsulation is the process of hiding data and methods within a class.
Inheritance allows a class to inherit properties and methods from another class.
Polymorphism allows obje...read more
Q65. How to design database structure
Database structure design involves identifying entities, relationships, attributes, and normalization.
Identify entities and their relationships
Define attributes for each entity
Normalize the database to reduce redundancy
Consider indexing for efficient querying
Use primary and foreign keys to establish relationships
Choose appropriate data types for each attribute
Q66. what is object ?what is oops
An object is an instance of a class in object-oriented programming. OOPs stands for Object-Oriented Programming System.
An object is a real-world entity that has state and behavior.
Objects are instances of classes, which define their structure and behavior.
OOPs is a programming paradigm based on the concept of objects.
Encapsulation, inheritance, polymorphism, and abstraction are key principles of OOPs.
Example: A car can be an object with properties like color, model, and behav...read more
Q67. String buffer and string boot difference
String buffer is mutable while string builder is not. String builder is faster but not thread-safe.
String buffer is synchronized and thread-safe, while string builder is not.
String builder is faster than string buffer because it is not synchronized.
String buffer is mutable, meaning it can be changed after creation, while string builder is immutable.
Example: StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
Q68. What is Reactjs What is DOM Closures Promises
Reactjs is a JavaScript library for building user interfaces. DOM is a programming interface for web documents. Closures and Promises are JavaScript concepts.
Reactjs is a popular JavaScript library for building interactive user interfaces.
DOM stands for Document Object Model, which is a programming interface for web documents.
Closures in JavaScript allow functions to retain access to variables from their containing scope even after the scope has closed.
Promises are objects re...read more
Q69. what is servlet implement code
Servlet implement code is the code that defines the behavior of a servlet in a Java web application.
Servlet implement code is written in Java and typically extends the HttpServlet class.
It includes methods like doGet() and doPost() to handle HTTP GET and POST requests.
Servlet implement code can interact with databases, process form data, and generate dynamic web content.
Q70. what is rdbms and use
RDBMS stands for Relational Database Management System. It is a type of database management system that stores data in a structured format.
Organizes data into tables with rows and columns
Uses SQL for querying and managing data
Enforces relationships between tables using foreign keys
Examples include MySQL, PostgreSQL, Oracle
Q71. what is microservies anduse
Microservices are a software development technique where applications are broken down into smaller, independent services that communicate with each other.
Each microservice is responsible for a specific function or feature
Microservices can be developed, deployed, and scaled independently
Communication between microservices is typically done through APIs
Examples: Netflix, Amazon, Uber
Q72. What is OAuth 2.0?
OAuth 2.0 is an authorization framework that allows third-party applications to access user data without sharing passwords.
OAuth 2.0 is used for authentication and authorization.
It allows users to grant access to their resources stored on one site to another site.
It uses access tokens to grant access to resources.
Examples of OAuth 2.0 providers include Google, Facebook, and Twitter.
Q73. 1. why string is immutable
String is immutable because it ensures data integrity, thread safety, and allows for efficient memory management.
Immutable strings prevent accidental modification of data.
Immutable strings can be safely shared across multiple threads.
Immutable strings allow for efficient memory management by reusing existing string instances.
Immutable strings enable the use of string interning for better performance.
Immutable strings facilitate the implementation of hash-based data structures...read more
Q74. Explain OSI model modules?
The OSI model is a conceptual model that characterizes and standardizes the communication functions of a telecommunication or computing system.
The OSI model has 7 layers: Physical, Data Link, Network, Transport, Session, Presentation, and Application.
Each layer has a specific function and communicates with the layers above and below it.
The Physical layer deals with the physical transmission of data, while the Application layer deals with user interfaces and application proces...read more
Q75. What are pipes in angular?
Pipes in Angular are used for transforming data in templates.
Pipes are used to format data before displaying it in the view.
Angular provides built-in pipes like date, currency, uppercase, lowercase, etc.
Custom pipes can also be created for specific formatting needs.
Pipes can be chained together for multiple transformations.
Example: {{ birthday | date:'MM/dd/yyyy' }}
Q76. collection and type of collection in jva
Java provides various types of collections like List, Set, Map, Queue, etc.
Java collections framework provides interfaces and classes to store and manipulate groups of objects.
Some common types of collections in Java are ArrayList, LinkedList, HashSet, HashMap, PriorityQueue, etc.
Collections in Java can be used to store and manipulate data in a structured way.
Collections provide methods to add, remove, search, and iterate over elements efficiently.
Q77. what is filter in java 8
Filter in Java 8 is a method used to iterate through a collection and filter out elements based on a specified condition.
Filter is a method in the Stream interface in Java 8.
It takes a Predicate as an argument to specify the condition for filtering.
Example: List
names = Arrays.asList("Alice", "Bob", "Charlie"); List filteredNames = names.stream().filter(name -> name.startsWith("A")).collect(Collectors.toList());
Q78. Postgres query for, group by operation.
Postgres query for grouping data based on a specific column.
Use the GROUP BY clause in your query
Specify the column you want to group by in the GROUP BY clause
Aggregate functions like COUNT, SUM, AVG can be used with GROUP BY
Example: SELECT column_name, COUNT(*) FROM table_name GROUP BY column_name
Q79. write jwt implementation methods
JWT implementation methods involve encoding, decoding, and verifying tokens for secure authentication.
Use a library like jsonwebtoken to easily create and verify JWT tokens
When creating a token, include a payload with user information and a secret key for signing
To verify a token, decode it using the secret key and check the signature
Q80. Talk about non-technical topic for 3 min
Discussing the impact of social media on mental health
Social media can have both positive and negative effects on mental health
Excessive use of social media can lead to feelings of inadequacy and low self-esteem
However, social media can also provide a sense of community and support for individuals going through tough times
Q81. What is SPA in software
SPA stands for Single Page Application, a web application that loads a single HTML page and dynamically updates as the user interacts with it.
SPA loads a single HTML page initially and updates content dynamically without reloading the entire page
Uses AJAX to fetch data from the server and update the page without refreshing
Improves user experience by providing faster navigation and smoother interactions
Examples include Gmail, Facebook, and Google Maps
Q82. What is a class?
A class is a blueprint for creating objects in object-oriented programming.
Defines the properties and behaviors of objects
Can be used to create multiple instances of objects
Encapsulates data and methods within a single unit
Q83. What is an object?
An object is a self-contained entity that consists of data and methods to manipulate that data.
Objects are instances of classes in object-oriented programming.
They have attributes (data) and methods (functions) to operate on the data.
Objects can interact with each other through method calls.
Example: In a car simulation program, a 'Car' object may have attributes like 'color' and 'speed', and methods like 'accelerate' and 'brake'.
Q84. What are data structures
Data structures are ways to organize and store data in a computer so that it can be accessed and used efficiently.
Data structures define how data is stored, accessed, and manipulated in a computer program.
Examples include arrays, linked lists, stacks, queues, trees, and graphs.
Choosing the right data structure is crucial for optimizing performance and memory usage in software development.
Q85. Can deactivate in Angular
Yes, you can deactivate in Angular using the ngIf directive.
Use ngIf directive to conditionally show or hide elements in Angular templates.
Set the condition to false to deactivate the element.
Example:
Content
Q86. what is oops concets
Object-oriented programming concepts that focus on classes and objects.
Encapsulation: Bundling data and methods that operate on the data into a single unit (class).
Inheritance: Ability of a class to inherit properties and behavior from another class.
Polymorphism: Ability to present the same interface for different data types.
Abstraction: Hiding the complex implementation details and showing only the necessary features.
Example: Class 'Car' with properties like 'color' and meth...read more
Q87. explain Polymorphism with examples
Polymorphism is the ability of an object to take on many forms. It allows objects of different classes to be treated as the same type.
Polymorphism allows a single interface to be used for different types of objects.
It helps in achieving code reusability and flexibility.
Polymorphism can be achieved through method overriding and method overloading.
Example: A 'Shape' class can have different subclasses like 'Circle', 'Rectangle', and 'Triangle', all implementing a 'draw' method.
Q88. What is View in Sql?
View in SQL is a virtual table that is based on the result-set of an SQL statement.
A view is a stored SELECT statement that can be used as a table.
It is used to simplify complex queries and to hide the complexity of underlying tables.
Views can be used to restrict access to sensitive data.
They do not store data themselves, but rather retrieve data from one or more tables.
Views can be created using the CREATE VIEW statement.
Q89. Java opps concept and implementation
Java OOPs concepts refer to the principles of Object-Oriented Programming and their implementation in Java.
Java OOPs concepts include inheritance, encapsulation, polymorphism, and abstraction.
Inheritance allows a class to inherit properties and behavior from another class.
Encapsulation involves bundling data and methods that operate on the data into a single unit.
Polymorphism allows objects to be treated as instances of their parent class.
Abstraction involves hiding the imple...read more
Q90. What are Constraints in Oracle
Constraints in Oracle are rules that limit the type of data that can be inserted or updated in a table.
Constraints ensure data integrity and consistency.
Types of constraints include NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY, and CHECK constraints.
NOT NULL constraint ensures that a column cannot have a NULL value.
UNIQUE constraint ensures that each value in a column is unique.
PRIMARY KEY constraint ensures that each row in a table is uniquely identified.
FOREIGN KEY constraint...read more
Q91. string concat operation output
The question is about the output of a string concatenation operation.
The output of a string concatenation operation is a new string that combines the original strings.
The order of the strings in the concatenation operation determines the order in the output.
The concatenation operator in most programming languages is the plus sign (+).
Q92. what is virtual dom
Virtual DOM is a lightweight copy of the actual DOM used for efficient updates in web development.
Virtual DOM is a concept used in frameworks like React to improve performance by minimizing actual DOM updates.
Changes are first made to the virtual DOM, which is then compared to the actual DOM to determine the minimal updates needed.
This process helps in reducing the number of manipulations required on the real DOM, leading to faster rendering.
Virtual DOM allows for efficient b...read more
Q93. Delegate in csharp and example
Delegate in C# allows a method to be passed as a parameter or assigned to a variable.
Delegates are similar to function pointers in C++.
Delegates can be used to create callback functions.
Example: defining a delegate, assigning a method to it, and invoking the delegate.
Q94. create rest controller
Creating a REST controller involves defining endpoints to handle HTTP requests and responses.
Define a class annotated with @RestController
Define methods within the class annotated with @RequestMapping to handle different HTTP methods and paths
Use @GetMapping, @PostMapping, @PutMapping, @DeleteMapping annotations for specific HTTP methods
Inject dependencies using @Autowired annotation if needed
Q95. Microservices Design Pattern
Microservices design pattern is an architectural style that structures an application as a collection of loosely coupled services.
Each service is responsible for a specific business function and can be developed, deployed, and scaled independently.
Communication between services is typically done through APIs, allowing for flexibility and resilience.
Microservices promote agility, scalability, and maintainability in large and complex systems.
Examples of companies using microser...read more
Q96. write code using Streams API
Using Streams API to write code for software development tasks.
Use Stream.of() to create a stream from a list of elements
Use filter() to apply a predicate to filter elements
Use map() to transform elements in the stream
Use collect() to convert the stream into a collection
Q97. Internal structure of Hashmap
Hashmap is a data structure that stores key-value pairs and uses hashing to map keys to values.
Hashmap is implemented using an array of linked lists.
Each element in the array is a bucket that can store multiple key-value pairs.
When inserting a key-value pair, the key is hashed to determine the index in the array where it will be stored.
If multiple keys hash to the same index, a collision occurs and the key-value pairs are stored in the same bucket.
To retrieve a value, the key...read more
Q98. future of ev in india
The future of electric vehicles (EVs) in India looks promising with increasing government support and growing awareness about environmental issues.
Government incentives and subsidies are encouraging the adoption of EVs in India.
Improving infrastructure for charging stations will further boost the EV market.
Rising fuel prices and concerns about air pollution are driving the demand for EVs.
Companies like Tata Motors, Mahindra Electric, and Ola Electric are investing in EV techn...read more
Q99. SQL vs NoSQL difference
SQL is a relational database management system, while NoSQL is a non-relational database management system.
SQL is table-based, with a predefined schema, while NoSQL is document-based, key-value pairs, graph databases, or wide-column stores.
SQL is best suited for complex queries and transactions, while NoSQL is better for hierarchical data storage and real-time web applications.
Examples of SQL databases include MySQL, Oracle, and PostgreSQL, while examples of NoSQL databases i...read more
Q100. Solid principles in c#
Solid principles are a set of design principles for writing maintainable and scalable code in C#.
Single Responsibility Principle (SRP) - a class should have only one reason to change
Open/Closed Principle (OCP) - a class should be open for extension but closed for modification
Liskov Substitution Principle (LSP) - derived classes should be substitutable for their base classes
Interface Segregation Principle (ISP) - clients should not be forced to depend on interfaces they do not...read more
More about working at Capgemini
Top HR Questions asked in Hindustan Petroleum
Interview Process at Hindustan Petroleum
Top Software Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month