0% found this document useful (0 votes)
20 views4 pages

Core Java Interview Questions Full

The document contains over 60 core Java interview questions and answers covering fundamental concepts such as Java's platform independence, OOP principles, exception handling, and memory management. It also explains key differences between various Java components like JDK, JRE, and JVM, as well as collections and threading. Additionally, it highlights Java's popularity due to its security, robustness, and versatility in application development.

Uploaded by

Amar kumar Sahoo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views4 pages

Core Java Interview Questions Full

The document contains over 60 core Java interview questions and answers covering fundamental concepts such as Java's platform independence, OOP principles, exception handling, and memory management. It also explains key differences between various Java components like JDK, JRE, and JVM, as well as collections and threading. Additionally, it highlights Java's popularity due to its security, robustness, and versatility in application development.

Uploaded by

Amar kumar Sahoo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CORE JAVA INTERVIEW QUESTIONS & ANSWERS (60+)

1. What is Java?
Java is a high-level, object-oriented, platform-independent programming language used to develop secure and
scalable applications.

2. Why is Java platform-independent?


Java code is compiled into bytecode, which can run on any operating system using the Java Virtual Machine (JVM).

3. Difference between JDK, JRE, and JVM?


JVM executes bytecode. JRE includes JVM and core libraries. JDK includes JRE plus development tools like
compiler and debugger.

4. What is bytecode?
Bytecode is an intermediate code generated by the Java compiler that is executed by the JVM.

5. Is Java completely object-oriented?


No, Java is not 100% object-oriented because it supports primitive data types like int, char, etc.

6. What are the four OOP principles?


Encapsulation, Inheritance, Polymorphism, and Abstraction.

7. What is Encapsulation?
Encapsulation is the process of wrapping data and methods together and restricting access using access modifiers.

8. What is Inheritance?
Inheritance allows one class to acquire the properties and methods of another class using the extends keyword.

9. Why multiple inheritance is not supported in Java?


To avoid ambiguity caused by the diamond problem.

10. What is Polymorphism?


Polymorphism allows a method to perform different tasks based on the object calling it.

11. Difference between method overloading and overriding?


Overloading is compile-time polymorphism with same method name and different parameters. Overriding is runtime
polymorphism with same method signature.

12. What is Abstraction?


Abstraction hides implementation details and shows only essential functionality.

13. Abstract class vs Interface?


Abstract class can have concrete methods and variables. Interface supports multiple inheritance and only abstract
methods (Java 7).

14. What is static keyword?


Static members belong to the class rather than to objects.

15. What is final keyword?


Final variable cannot be changed, final method cannot be overridden, and final class cannot be inherited.

16. What is this keyword?


This refers to the current calling object.

17. What is super keyword?


Super refers to the immediate parent class object.

18. Can static methods be overridden?


No, static methods cannot be overridden.

19. Why String is immutable?


For security, synchronization, caching, and performance reasons.

20. Difference between String, StringBuilder, and StringBuffer?


String is immutable, StringBuilder is mutable and not thread-safe, StringBuffer is mutable and thread-safe.

21. What is String Pool?


It is a special memory area in heap where string literals are stored.

22. Difference between == and equals()?


== compares references, equals() compares actual content.

23. What are Wrapper classes?


Wrapper classes convert primitive data types into objects.

24. What is Exception?


An exception is an abnormal condition that occurs during runtime.

25. Checked vs Unchecked Exception?


Checked exceptions are verified at compile-time. Unchecked exceptions occur at runtime.

26. What is try-catch-finally?


It is used to handle exceptions and ensure execution of cleanup code.

27. Can we have try without catch?


Yes, try can be used with finally block.

28. Difference between throw and throws?


Throw is used to explicitly throw an exception. Throws is used to declare exceptions.

29. Difference between Array and ArrayList?


Array has fixed size and can store primitives. ArrayList is dynamic and stores objects.

30. What is Collection Framework?


It is a unified architecture for storing and manipulating groups of objects.

31. Difference between List and Set?


List allows duplicate elements, Set does not.

32. Difference between HashMap and Hashtable?


HashMap is not synchronized and allows one null key. Hashtable is synchronized and does not allow null.

33. What is JVM?


JVM is an engine that executes Java bytecode.

34. JVM memory areas?


Heap, Stack, Method Area, PC Register, Native Stack.

35. What is Heap memory?


Heap stores objects and class instances.

36. What is Stack memory?


Stack stores method calls and local variables.

37. What is Garbage Collection?


Automatic process of removing unused objects from memory.

38. Can we call Garbage Collector manually?


We can request it using [Link](), but JVM decides.

39. What is Thread?


A thread is the smallest unit of execution.

40. Ways to create thread?


By extending Thread class or implementing Runnable interface.

41. Difference between Thread and Runnable?


Runnable allows multiple inheritance while Thread does not.

42. What is synchronization?


It controls access to shared resources in multithreading.

43. What is Lambda expression?


Lambda is an anonymous function introduced in Java 8.

44. What is Stream API?


It processes collections in a functional programming style.

45. What is Functional Interface?


An interface with exactly one abstract method.

46. Can main method be overloaded?


Yes, but JVM always calls the standard main method.

47. Why main method is static?


So JVM can call it without creating an object.

48. Can constructor be inherited?


No, constructors cannot be inherited.

49. What is constructor?


A constructor is used to initialize objects.

50. Constructor vs Method?


Constructor initializes objects and has no return type. Method performs operations and has return type.

51. What is default constructor?


A constructor with no parameters provided by compiler.

52. Can constructor be private?


Yes, to restrict object creation (Singleton).

53. What is Singleton class?


A class that allows only one instance.

54. What is serialization?


Process of converting object into byte stream.

55. What is transient keyword?


It prevents variable from being serialized.

56. What is marker interface?


An interface without methods (e.g., Serializable).

57. Shallow copy vs Deep copy?


Shallow copies references, deep copy duplicates objects.

58. What is default access modifier?


Package-private access.

59. Can interface have constructor?


No, interfaces cannot have constructors.

60. Why Java is popular?


Because it is platform-independent, secure, robust, and widely used.

You might also like