OOPS WITH JAVA – Viva Questions (3rd Sem CSE)
1. What is Object-Oriented Programming (OOP)?
OOP is a programming approach that uses objects and classes to structure programs.
2. What is a Class?
A class is a blueprint/template that defines properties and behaviors of an object.
3. What is an Object?
An object is an instance of a class that has state (data) and behavior (methods).
4. Main OOP principles:
- Encapsulation
- Inheritance
- Polymorphism
- Abstraction
5. What is Encapsulation?
Wrapping data and methods together and restricting access using access modifiers.
6. Why Getters and Setters?
To control access to private variables.
7. What is Inheritance?
When one class (child) acquires properties of another class (parent).
8. Types of Inheritance in Java:
Single, Multilevel, Hierarchical (Java does not support multiple inheritance with classes)
9. What is Polymorphism?
Same action behaving in different ways.
10. Method Overloading:
Same method name, different parameter list.
11. Method Overriding:
Same method name + same parameters, defined in child class.
12. What is Abstraction?
Showing essential features and hiding unnecessary details.
13. Achieving Abstraction:
Using abstract classes and interfaces.
14. What is an Interface?
A fully abstract class with abstract methods (Java 8+ allows default and static methods).
15. Abstract Class vs Interface:
- Abstract class can have concrete methods, interface cannot (before Java 8).
- Abstract class supports constructors, interface does not.
- Interface supports multiple inheritance.
16. What is a Constructor?
A special method used to initialize objects.
17. Types of Constructors:
Default, Parameterized, Copy constructor (manual in Java).
18. static keyword:
Belongs to class, not object.
19. this keyword:
Refers to current object.
20. super keyword:
Refers to parent class members.
21. What is a Package?
A folder that groups related classes.
22. Exception Handling:
Handling runtime errors using try, catch, throw, throws, finally.
23. Checked vs Unchecked Exceptions:
Checked → compile time
Unchecked → runtime
24. JVM:
Java Virtual Machine — executes bytecode.
25. JDK vs JRE:
JDK → compiler + tools
JRE → JVM + libraries