Java Interview Questions for Salesforce Role
1. 1. What are the main principles of Object-Oriented Programming (OOP)?
Encapsulation, Inheritance, Polymorphism, and Abstraction.
2. 2. How is abstraction implemented in Java?
Using abstract classes and interfaces. Abstract classes can have both abstract and concrete
methods, while interfaces contain only abstract methods (prior to Java 8).
3. 3. What is the difference between `==` and `.equals()` in Java?
`==` checks for reference equality, whereas `.equals()` checks for value/content equality
(can be overridden for custom comparison).
4. 4. What is the difference between an interface and an abstract class?
Interfaces support multiple inheritance and are purely abstract (until Java 8). Abstract
classes allow some implementation and are used when you want to share code among
several related classes.
5. 5. How can you integrate Java applications with Salesforce?
Using Salesforce REST API, SOAP API, or Bulk API. Java libraries like HttpClient,
RestTemplate, or Postman can be used to make API calls.
6. 6. What is OAuth in Salesforce integration and how do you use it in Java?
OAuth is an authentication mechanism used by Salesforce. Java can use OAuth 2.0 to get an
access token by making a POST request to the Salesforce token URL.
7. 7. What is a Connected App in Salesforce?
A Connected App allows external apps (like Java) to securely connect to Salesforce using
OAuth.
8. 8. What is the difference between ArrayList and LinkedList?
ArrayList provides faster access (O(1)) but slower inserts/removals. LinkedList has slower
access but faster inserts/removals in the middle of the list.
9. 9. What is the use of HashMap in Java?
HashMap is used to store key-value pairs. It provides constant-time performance (O(1)) for
get and put operations, assuming good hash distribution.
10. 10. How do you sort a list of objects in Java?
Use [Link]() with a Comparator or Comparable implementation.
11. 11. What is the difference between `throw` and `throws` in Java?
`throw` is used to explicitly throw an exception, while `throws` declares exceptions a
method might throw.
12. 12. What is a checked vs unchecked exception?
Checked exceptions are checked at compile-time (e.g., IOException), while unchecked
exceptions occur at runtime (e.g., NullPointerException).
13. 13. How do you create a thread in Java?
By extending Thread or implementing Runnable, then calling start().
14. 14. What is the difference between synchronized method and synchronized block?
A synchronized method locks the whole method, while a synchronized block can lock only a
portion of the code or a specific object.
15. 15. What is the use of volatile keyword in Java?
It ensures visibility of changes to variables across threads. It prevents caching of variables.
16. 16. What are Lambda Expressions?
They allow you to write anonymous functions in a concise way, often used with streams or
functional interfaces. Example: (a, b) -> a + b
17. 17. What is a Stream in Java 8?
A Stream is a sequence of elements supporting sequential and parallel aggregate operations.
It's used for functional-style operations on collections.
18. 18. What is the Optional class in Java 8?
It’s a container object to avoid NullPointerException. It helps in writing clean and null-safe
code.
19. 19. How do you handle JSON in Java for API integration with Salesforce?
Use libraries like Jackson, Gson, or [Link] to parse and generate JSON.
20. 20. How can you secure sensitive credentials (e.g., Salesforce access tokens) in Java
apps?
Use environment variables, encrypted configuration files, or secrets managers like AWS
Secrets Manager or Vault.