0% found this document useful (0 votes)
66 views

Infosys Interview Questions and Answers

Uploaded by

akmajith1998
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views

Infosys Interview Questions and Answers

Uploaded by

akmajith1998
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Infosys Interview Questions and Answers:

2. Do you know OOPS concepts and in framework where and how you have
implemented it?

Yes, OOPS concepts include Encapsulation, Inheritance, Polymorphism, and


Abstraction. In frameworks like Selenium:

Encapsulation: Used in Page Object Model (POM) to encapsulate locators and


actions within classes.

Inheritance: Base test classes are inherited by test scripts for reusability.
Polymorphism: Method overloading is used for different argument variations in utility
methods, while overriding is used for WebDriver methods.

Abstraction: Interfaces like WebDriver are implemented to define browser-specific


behaviors.
3. Can we declare a private class?

A top-level class cannot be private; only nested classes (inner classes) can be
declared private. This restricts their access to within the enclosing class.
4. What is the difference between == and equals?

==: Compares memory references.

equals: Compares the content or value of objects (overridden in classes like String).
5. How is a string immutable?

Strings are immutable because once created, their value cannot be changed. Any
modification creates a new string object, leaving the original unchanged.
6. Where do strings and their references get stored?

String literals are stored in the String Pool within the heap.

References to strings are stored on the stack.


7. How is a string immutable with reference to memory location?

When a string is modified (e.g., concatenated), a new object is created in the


memory (String Pool or heap), and the reference is updated to the new object,
leaving the original unchanged.
8. If not using the String class, what can be used?

You can use StringBuffer or StringBuilder for mutable strings.

9. Difference between String and StringBuffer?


String: Immutable, stored in String Pool, thread-safe.

StringBuffer: Mutable, stored in heap, thread-safe.


10. What collections have you used? Have you used HashMap?

I have used collections like List, Set, and Map.

HashMap: Used for storing key-value pairs where keys are unique.
11. List declaration?

List<String> list = new ArrayList<>();


12. Where have you used Set?

Set is used when we need to store unique elements, such as to remove duplicates
from a collection.
13. How to test the Flipkart cart scenario with quantity updates?

Add the same item twice and verify:

UI: Only one entry is displayed with quantity updated to 2.

Backend/API: Validate the request/response to ensure quantity is being updated


correctly.
14. Find the missing number from 1 to 100 flashed on screen.

Use the formula Sum = n * (n + 1) / 2. Subtract the sum of displayed numbers from
this total to find the missing number.
15. Which collection to store all table data and why?

List<List<String>> or ArrayList<ArrayList<String>> can be used to store row-wise


table data for easier access and manipulation.
16. What does HashMap return?

put(key, value): Returns the previous value associated with the key or null.

get(key): Returns the value mapped to the key or null.


17. How to achieve inheritance without using an interface?

Inheritance can be achieved through abstract classes.


18. Method overloading and overriding in frameworks?

Overloading: Used in utility classes, like methods handling different data types.

Overriding: Implemented in Selenium to customize WebDriver behaviors.


19. How to prevent a class from being extended or instantiated?
Prevent extension: Declare the class as final.

Prevent instantiation: Make the constructor private.


20. How to store multiple values in one reference?

Use arrays, collections like List or Map, or custom objects.


21. In Cucumber, where is glue code located, and how is it structured?

Glue code is in step definition classes. It is organized based on features/modules to


ensure maintainability, with each class having manageable lines of code (~200 lines
max).
22. Used static or dynamic data? What was your approach?

Both approaches are used:

Static Data: Hardcoded values for smoke tests.

Dynamic Data: Data-driven approach using Excel, databases, or APIs for real-world
scenarios.
23. How to resolve conflicts while pushing code in Git?

Use git pull to fetch changes from the remote repository.

Resolve conflicts in the affected files.

Mark resolved files using git add.

Commit the changes and push using git push.

You might also like