back to course
Lesson 79 / 8099%· free preview
Exam Prep1/2
Java Exam Questions
Most-asked Java theory + programs in B.Tech, MCA, and IT diploma exams.
Overview
Frequently-asked Java exam questions across theory, programs, OOP, and JDBC. Use to revise the night before.
1. Theory Questions
- What is Java? Who developed it? Object-oriented, platform-independent language; James Gosling, Sun Microsystems, 1995.
- JDK vs JRE vs JVM?
- JVM — runs
.classfiles - JRE — JVM + standard libraries (to RUN)
- JDK — JRE + compiler
javac(to BUILD)
- JVM — runs
- Why is Java platform independent?
javaccompiles to bytecode which any JVM can run — "Write Once, Run Anywhere." - What are the features of Java? OOP, robust, secure, multi-threaded, distributed, portable.
- Difference:
==vs.equals()?==compares references;.equals()compares values.
2. Common Programs
- WAP to check Armstrong / palindrome / prime.
- WAP to reverse a string without library.
- WAP to demonstrate single-level / multi-level / hierarchical inheritance.
- WAP for try-catch-finally with
ArithmeticException. - WAP using threads — extend
Threadand implementRunnable.
3. OOP Section (very high yield)
- 4 pillars: Encapsulation, Inheritance, Polymorphism, Abstraction.
- Method overloading — same name, different params (compile-time).
- Method overriding — subclass redefines parent method (run-time).
- Abstract class vs interface? Abstract can have non-abstract methods; interface (pre-Java 8) only abstract; both can't be instantiated.
supervsthis?super→ parent class members;this→ current object.
4. Output / Predict-the-output
javaSystem.out.println(10 + 20 + "Java"); // 30Java System.out.println("Java" + 10 + 20); // Java1020 int x = 5; System.out.println(x++ + ++x); // 12
5. JDBC / Collections (often asked)
- JDBC steps: Load driver → connect → statement → execute → process → close.
- ArrayList vs LinkedList? ArrayList: random access O(1), insert O(n). LinkedList: insert O(1), access O(n).
- HashMap vs HashTable? HashMap is unsynchronized + allows null; HashTable is synchronized + no null.
6. Pro Tips
- Always close DB connections in
finally(or use try-with-resources). Stringis immutable — manipulations create new objects.finalon var → constant; on method → can't override; on class → can't extend.- Mention garbage collection is automatic via
System.gc()hint.
AI-powered recap
Quick recap quiz?
We'll generate 5 MCQs from this lesson and check your understanding instantly. Takes ~30 seconds.
# program
Program
Java
// Quick OOP demo
class A { void show() { System.out.println("A"); } }
class B extends A { void show() { System.out.println("B"); } }
public class Main {
public static void main(String[] a) {
A x = new B();
x.show(); // B (run-time polymorphism)
}
}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
// did you know?
One surprising fact before your next lesson
Bite-sized programming facts that make your next coffee-break explanation land.
// feedback.matters()
Did this lesson help you?
