back to course
Lesson 80 / 80100%· free preview
Exam Prep2/2
Viva Questions
20 most-asked Java viva Q&A — short, exam-ready answers.
Common Java Viva Questions and Answers
- What is Java? Object-oriented, platform-independent, secure, multithreaded language by Sun Microsystems (now Oracle).
- What is bytecode? Intermediate code (
.class) produced byjavacand executed by the JVM. - What is JVM? Java Virtual Machine — runs bytecode, manages memory, garbage collection.
- JDK vs JRE? JDK = JRE + dev tools (compiler, debugger). JRE only runs.
- What is OOP? Programming style based on objects (data + behaviour). 4 pillars: Inheritance, Encapsulation, Polymorphism, Abstraction.
- What is a class and an object? Class = blueprint; object = instance of a class.
- What is constructor? Special method with same name as class, no return type, called automatically when object is created.
thisvssuper?this→ current object;super→ parent class.- Method overloading vs overriding? Overloading: same method name, different params (compile-time). Overriding: subclass changes parent's method (run-time).
- Difference between
final,finally,finalize?finalkeyword for constants;finallyblock always executes;finalize()called by GC before object is destroyed. - What is exception handling?
try / catch / finally / throw / throws— handle runtime errors gracefully. - Checked vs unchecked exception? Checked: compile-time enforced (
IOException). Unchecked: runtime (NullPointerException). - What is a thread? Lightweight subprocess. Create via
extends Threadorimplements Runnable. StringvsStringBuildervsStringBuffer? String — immutable. StringBuilder — mutable, fast, NOT thread-safe. StringBuffer — mutable + thread-safe.- What is collection framework? Set of interfaces & classes (List, Set, Map, Queue) for storing groups of objects.
- Why is Java not 100% OOP? Because it has primitive types (
int,char,double) — not objects. - What is package? Group of related classes — gives namespace + access protection.
- What is JDBC? Java DataBase Connectivity API — connects Java code to databases.
- What is
statickeyword? Belongs to the class, not any instance — shared across all objects. - Is Java pass-by-value or pass-by-reference? Always pass-by-value (but for objects, the value is a reference copy).
AI-powered recap
Quick recap quiz?
We'll generate 5 MCQs from this lesson and check your understanding instantly. Takes ~30 seconds.
Ready to move on?
// example library
Want more hands-on snippets in Java?
Browse 100 runnable examples · across 10 chapters · short, copy-paste-friendly · grouped by topic
// side-by-side reference
See this in other languages
Compare the same concept across C, C++, Java, and Python — one table, zero tab-switching.
// feedback.matters()
Did this lesson help you?
