UNIT-1: Basics of Java (Q1–15)
1. What is Java?
Java is a high-level, object-oriented, platform-independent programming language.
2. Why is Java platform independent?
Because Java programs run on JVM using bytecode, not machine code.
3. What is JVM?
Java Virtual Machine executes bytecode and provides platform independence.
4. What is JRE?
Java Runtime Environment contains JVM + runtime libraries required to run Java programs.
5. What is JDK?
Java Development Kit contains compiler (javac), libraries, tools, JRE.
6. Difference between JDK, JRE, and JVM?
| Component | Purpose |
|---|---|
| JVM | Executes bytecode |
| JRE | Environment to run Java |
| JDK | Develop + run Java |
7. What is Bytecode?
Intermediate representation executed by JVM.
8. What is a Class?
Blueprint for creating objects.
9. What is an Object?
Instance of a class having state and behavior.
10. What is main() method?
Entry point of Java program:
11. What is a variable?
Memory location to store data.
12. Types of variables
Local, Instance, Static.
13. What are data types in Java?
-
Primitive: int, byte, short, long, char, float, double, boolean
-
Non-primitive: arrays, classes, strings.
14. What is Type Casting?
Converting data type:
-
Implicit: small → large
-
Explicit: large → small
15. What is a Package?
Collection of classes and interfaces.
UNIT-2: OOP Concepts (Q16–30)
16. What is OOP?
Programming approach based on objects and classes.
17. 4 Pillars of OOP
Encapsulation, Abstraction, Inheritance, Polymorphism.
18. What is Encapsulation?
Wrapping data and methods into a single unit (class).
19. Abstraction
Hiding implementation details and showing only essential features.
20. Inheritance
One class acquires properties of another class using extends.
21. Polymorphism?
Ability to take multiple forms.
Types:
-
Compile-time (method overloading)
-
Runtime (method overriding)
22. Method Overloading
Same method name but different parameters.
23. Method Overriding
Sub-class provides its own implementation of superclass method.
24. What is Constructor?
Special method used to initialize objects.
25. Types of Constructors
Default, Parameterized, Copy constructor (not built-in but user-defined).
26. What is this keyword?
Refers to current class object.
27. What is super keyword?
Refers to parent class.
28. What is final keyword?
Used to prevent modification:
-
final variable → constant
-
final method → cannot override
-
final class → cannot inherit
29. Difference between Abstract Class and Interface
| Abstract Class | Interface |
|---|---|
| May have code | Only abstract methods (Java 8+: default/static allowed) |
| Supports constructor | No constructor |
30. Multiple Inheritance in Java?
Not supported using classes; supported using interfaces.
UNIT-3: Exception Handling & Multithreading (Q31–50)
31. What is an Exception?
Runtime error that disrupts program execution.
32. Exception Handling Keywords
try, catch, finally, throw, throws.
33. Example of exception handling
34. Checked vs Unchecked Exception
| Checked | Unchecked |
|---|---|
| Compile-time | Runtime |
| IOException | ArithmeticException |
35. What is finally block?
Executes always, even if exception occurs.
36. What is throw?
Used to manually throw exception.
37. What is throws?
Used in method signature to declare exceptions.
38. What is Multithreading?
Executing multiple tasks simultaneously.
39. Ways to create thread
-
Extend
Threadclass -
Implement
Runnableinterface
40. Thread example
41. Thread lifecycle
New → Runnable → Running → Blocked → Terminated
42. sleep() method
Pauses execution temporarily.
43. Thread Priority Range
1 (lowest) to 10 (highest)
44. Synchronization
Mechanism to control multiple thread access to shared resources.
45. Deadlock
Two threads waiting for each other forever.
46. yield()
Gives CPU to another waiting thread.
47. join()
Waits for a thread to finish.
48. isAlive()
Checks if thread is still running.
49. Daemon Thread
Background service thread (e.g., garbage collector).
50. Garbage Collection
Automatic memory management in Java.
UNIT-4: I/O, Collections & GUI (Q51–75)
51. What is Stream?
Sequence of data from source to destination.
52. Types of Streams
-
Byte streams
-
Character streams
53. File Handling Example
54. BufferedReader
Efficient character input stream.
55. What is Serialization?
Saving object state to file using Serializable.
56. What is Collection Framework?
Prebuilt classes for data structures in java.util.
57. List Interface
Ordered, allows duplicates (ArrayList, LinkedList).
58. Set Interface
No duplicates (HashSet, LinkedHashSet, TreeSet).
59. Map Interface
Key-value pairs (HashMap, TreeMap).
60. ArrayList
Resizable array implementation.
61. LinkedList
Doubly linked list structure.
62. Iterator
Used to traverse collections.
63. Comparable vs Comparator
Comparable → natural sorting
Comparator → custom sorting
64. AWT
Abstract Window Toolkit for GUI development.
65. Event Handling
Responding to user actions (mouse, keyboard).
66. Swing
Advanced GUI toolkit (better than AWT).
67. JFrame
Top-level Swing window.
68. Layout Managers
Flow, Border, Grid, Box layouts.
69. JButton Example
70. Applet
Java program running in browser (now obsolete).
71. JDBC
API to connect Java with databases.
72. JDBC Steps
Driver load → Connection → Statement → Query → Close connection.
73. Example of JDBC Connection
74. PreparedStatement
Precompiled SQL statement.
75. Advantages of Java
Secure, portable, distributed, multithreaded, robust, platform independent.
Comments
Leave a Comment
Your email address will not be published. Required fields are marked *