π Top 50 Interview Questions β Object-Oriented Programming (OOP) #9
Unanswered
hirenpatel1903
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
π Top 50 Interview Questions β Object-Oriented Programming (OOP)
This repository contains Top 50 frequently asked interview questions covering Object-Oriented Programming (OOP) and core Java concepts.
It is designed for freshers, students, and experienced developers preparing for technical interviews.
π Table of Contents
π§± Object-Oriented Programming (OOP)
1. What is OOP?
Answer:
OOP (Object-Oriented Programming) is a programming paradigm based on objects and classes to structure software in a reusable, scalable, and maintainable way.
2. What are the four main principles of OOP?
Answer:
3. What is encapsulation?
Answer:
Encapsulation is the process of bundling data (variables) and methods that operate on that data into a single unit (class) and restricting direct access.
4. What is inheritance?
Answer:
Inheritance allows a class to acquire properties and behaviors of another class, promoting code reusability.
5. What is polymorphism?
Answer:
Polymorphism allows a method to behave differently based on the object that invokes it.
6. What is abstraction?
Answer:
Abstraction hides implementation details and exposes only essential features.
7. Difference between class and object?
Answer:
8. What is a constructor?
Answer:
A constructor is a special method used to initialize objects of a class.
9. What is method overloading?
Answer:
Defining multiple methods with the same name but different parameter lists.
10. What is method overriding?
Answer:
Providing a new implementation of a parent class method in a subclass.
11. What is an exception?
Answer:
An exception is an event that disrupts the normal flow of program execution.
12. Difference between checked and unchecked exceptions?
Answer:
13. What is try-catch?
Answer:
Used to handle exceptions and prevent program termination.
14. Purpose of finally block?
Answer:
Executes code regardless of whether an exception occurs.
15. What is
throwkeyword?Answer:
Used to explicitly throw an exception.
16. What is
throwskeyword?Answer:
Used to declare exceptions that a method may pass to the caller.
17. Difference between throw and throws?
Answer:
throw: Throws an exceptionthrows: Declares possible exceptions18. What is a custom exception?
Answer:
A user-defined exception created by extending
ExceptionorRuntimeException.19. What is try-with-resources?
Answer:
Automatically closes resources after execution.
20. What are runtime exceptions?
Answer:
Exceptions that occur during program execution due to logical errors.
π€ Strings
21. What is a String in Java?
Answer:
An immutable object representing a sequence of characters.
22. Difference between String, StringBuilder, StringBuffer?
Answer:
23. How to compare strings?
Answer:
Using the
equals()method.24. What is intern()?
Answer:
Returns a canonical representation of a string from the string pool.
25. What is string concatenation?
Answer:
Combining strings using
+orconcat().26. Convert string to integer?
Answer:
Integer.parseInt()27. What is substring()?
Answer:
Extracts a portion of a string using index values.
28. What is String.format()?
Answer:
Used to create formatted strings.
29. How to check if a string contains text?
Answer:
Use the
contains()method.30. What is StringBuilder used for?
Answer:
Efficient manipulation of mutable strings.
π§΅ Multithreading
31. What is a thread?
Answer:
A lightweight process that executes tasks independently.
32. Runnable vs Thread?
Answer:
33. How to create a thread?
Answer:
ThreadclassRunnableinterface34. What is synchronized?
Answer:
Ensures only one thread accesses a shared resource at a time.
35. What is deadlock?
Answer:
A situation where threads wait indefinitely for resources.
36. What is thread safety?
Answer:
Code behaves correctly when accessed by multiple threads.
37. What is join()?
Answer:
Waits for a thread to complete execution.
38. What is volatile?
Answer:
Ensures visibility of variable changes across threads.
39. Thread states?
Answer:
New, Runnable, Blocked, Waiting, Timed Waiting, Terminated.
40. What is a thread pool?
Answer:
A group of reusable threads for executing tasks efficiently.
π¦ Collections
41. What is Java Collections Framework?
Answer:
A unified architecture for storing and manipulating collections.
42. List vs Set vs Map?
Answer:
43. What is ArrayList?
Answer:
Resizable array implementation of List.
44. What is HashSet?
Answer:
Unordered collection with no duplicates.
45. What is LinkedList?
Answer:
Doubly-linked list implementation.
46. What is HashMap?
Answer:
Stores key-value pairs using hashing.
47. HashMap vs TreeMap?
Answer:
48. What is PriorityQueue?
Answer:
Queue ordered by priority.
49. What is LinkedHashMap?
Answer:
Maintains insertion order.
50. How to iterate over collections?
Answer:
Using Iterator or enhanced for-loop.
π§ Interview Tips
π Follow & Subscribe
π Live YouTube Statistics
π Subscribe here: https://www.youtube.com/@einzigartige_/
Beta Was this translation helpful? Give feedback.
All reactions