Java Programming with Data Structures - Important Theory Questions
1. What is Object-Oriented Programming (OOP)? Explain its features.
OOP is a programming style based on real-world objects. It focuses on objects rather than procedures.
Features:
- Abstraction
- Encapsulation
- Inheritance
- Polymorphism
2. Differentiate between method overloading and method overriding.
Method Overloading: Same method name, different parameters (compile-time).
Method Overriding: Same method name & parameters in subclass (runtime).
3. Explain types of inheritance in Java.
Types: Single, Multilevel, Hierarchical.
Java doesn't support multiple inheritance with classes.
4. Write features of Java.
Platform Independent, OOP, Robust, Secure, Multithreaded, Portable, Dynamic
5. Structure of Java program
Example:
class Hello {
public static void main(String[] args) {
System.out.println("Hello World");
6. What is type casting in Java?
Java Programming with Data Structures - Important Theory Questions
Implicit: int x = 10; double y = x;
Explicit: double x = 10.5; int y = (int)x;
7. Explain Java tokens.
Tokens: Keywords, Identifiers, Literals, Operators, Separators
8. Control statements in Java
Decision: if, switch
Looping: for, while, do-while
Jump: break, continue, return
9. Primitive vs Non-primitive data types
Primitive: int, float
Non-Primitive: Array, String, Object
10. Classes and objects in Java
Class: Blueprint
Object: Instance of class
Example: Student s = new Student();
11. Constructors in Java
Default: No params
Parameterized: Takes args
Example: Student() {...}
12. Access Modifiers
private, default, protected, public - defines access scope
Java Programming with Data Structures - Important Theory Questions
13. Creating Threads in Java
Using Thread class or Runnable interface
14. Difference between String and StringBuffer
String: Immutable, StringBuffer: Mutable, thread-safe
15. Abstract Class vs Interface
Abstract Class: Abstract + concrete methods
Interface: Only abstract methods
16. What is exception handling in Java?
try-catch-finally, throw, throws - handles runtime errors
17. Multiple catch blocks
try { } catch(Exception1 e) { } catch(Exception2 e) { }
18. Bubble Sort Algorithm
Nested loop to compare and swap adjacent elements.
19. Stack Operations (Array)
push(), pop(), peek() with array implementation
20. Tree Traversal Techniques
Inorder, Preorder, Postorder - recursive methods