Add office photos
Engaged Employer

Codingal

4.2
based on 38 Reviews
Filter interviews by

10+ Hindustan Petroleum Interview Questions and Answers

Updated 26 Oct 2024

Q1. what are loops? arrays, conditional statments

Ans.

Loops, arrays, and conditional statements are fundamental programming concepts.

  • Loops allow for repetitive execution of code based on a condition or a set number of iterations.

  • Arrays are collections of data that can be accessed and manipulated using an index.

  • Conditional statements allow for the execution of different code based on a specified condition.

  • Examples: for loop, while loop, do-while loop, if statement, switch statement, foreach loop.

Add your answer

Q2. Programming languages you are comfortable with?

Ans.

I am comfortable with Java, Python, and C++.

  • Proficient in Java with experience in developing web applications using Spring framework

  • Skilled in Python for data analysis and machine learning projects

  • Familiar with C++ for competitive programming and algorithm development

Add your answer

Q3. Explain switch and one program using switch

Ans.

Switch is a control statement used to select one of many code blocks to be executed.

  • Switch statement evaluates an expression and compares it with multiple cases

  • If a match is found, the code block associated with that case is executed

  • If no match is found, the default code block is executed

  • Example: switch(expression) { case 1: //code block; break; case 2: //code block; break; default: //code block; }

Add your answer

Q4. What is OOPS programs you are comfortable with

Ans.

I am comfortable with OOPS programs such as Java, C++, and Python.

  • Proficient in Java OOPS concepts such as Inheritance, Polymorphism, and Encapsulation

  • Familiar with C++ OOPS concepts such as Abstraction, Constructors, and Destructors

  • Experienced in Python OOPS concepts such as Classes, Objects, and Inheritance

Add your answer
Discover Hindustan Petroleum interview dos and don'ts from real experiences

Q5. Define data structure?

Ans.

A data structure is a way of organizing and storing data in a computer so that it can be accessed and manipulated efficiently.

  • Data structures provide a means to manage and organize data effectively.

  • They define the relationship between data elements and enable operations to be performed on the data.

  • Examples of data structures include arrays, linked lists, stacks, queues, trees, and graphs.

View 1 answer

Q6. Explain conditional statements .

Ans.

Conditional statements are used to execute certain code based on a specific condition being met.

  • Conditional statements are often written using if/else statements

  • The condition is placed inside the parentheses after the if keyword

  • If the condition is true, the code inside the if block is executed, otherwise the code inside the else block is executed

  • Example: if(x > 5) {do something} else {do something else}

Add your answer

Q7. program to print prime numbers

Ans.

Program to print prime numbers

  • Start with a loop from 2 to n (number to check)

  • For each number, check if it is divisible by any number from 2 to its square root

  • If not divisible, it is a prime number and print it

Add your answer

Q8. code in the code.org platform

Ans.

Code in the code.org platform

  • Use block-based coding to create programs

  • Drag and drop blocks to sequence commands

  • Test and debug your code to ensure it runs correctly

Add your answer

Q9. Explain difference between constructor and destructor

Ans.

Constructor is used to initialize an object when it is created, while destructor is used to clean up resources when an object is destroyed.

  • Constructor is called when an object is created, while destructor is called when an object is destroyed.

  • Constructors can have parameters to initialize the object, while destructors do not take any parameters.

  • Example: Constructor initializes member variables of a class, while destructor releases any resources acquired by the object.

Add your answer

Q10. Uses of functions

Ans.

Functions are used to encapsulate a set of instructions that can be reused multiple times in a program.

  • Functions help in organizing code and making it more readable.

  • Functions allow for code reusability, reducing redundancy.

  • Functions can take input parameters and return output values.

  • Functions can be used to implement complex algorithms or logic.

  • Examples: calculating factorial, sorting elements, validating user input.

Add your answer
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos

Interview Process at Hindustan Petroleum

based on 4 interviews in the last 1 year
Interview experience
4.5
Good
View more
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Interview Questions from Similar Companies

3.8
 • 1.5k Interview Questions
4.0
 • 518 Interview Questions
3.5
 • 447 Interview Questions
4.1
 • 359 Interview Questions
3.8
 • 130 Interview Questions
View all
Top Codingal Interview Questions And Answers
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
70 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter