Questions and answers
What is the difference between JDK, JRE and JVM?
JVM runs bytecode. JRE is the JVM plus libraries needed to run programs. JDK is the JRE plus development tools such as the compiler (javac).
Why is Java platform independent?
Java source compiles to bytecode, which runs on any device that has a JVM.
What are the four pillars of OOP?
Encapsulation, inheritance, polymorphism and abstraction.
What is the difference between overloading and overriding?
Overloading: same method name with different parameters in the same class, resolved at compile time. Overriding: a subclass redefines a parent method with the same signature, resolved at run time.
What is a constructor?
A special method with the class name and no return type that runs when an object is created to initialise it.
What is the difference between an abstract class and an interface?
An abstract class can have fields and both abstract and concrete methods, and a class extends only one. An interface declares a contract; a class can implement many.
What is the use of the static keyword?
Static members belong to the class, not to an object, and can be used without creating an instance.
What is the difference between final, finally and finalize?
final makes a variable constant, a method non-overridable or a class non-inheritable. finally is a block that always runs after try-catch. finalize was a method called before garbage collection and is now deprecated.
What is exception handling?
A mechanism using try, catch, finally, throw and throws to handle run-time errors without crashing the program.
What is the difference between checked and unchecked exceptions?
Checked exceptions are verified at compile time (IOException, SQLException). Unchecked exceptions occur at run time (NullPointerException, ArithmeticException).
What is the difference between ArrayList and LinkedList?
ArrayList uses a dynamic array and is fast for random access. LinkedList uses nodes and is faster for frequent insertions and deletions.
What is the difference between HashMap and Hashtable?
HashMap is not synchronised and allows one null key. Hashtable is synchronised and allows no null key or value.
What are the steps to connect Java to a database using JDBC?
Load the driver, create a connection with DriverManager, create a Statement or PreparedStatement, execute the query, process the ResultSet, and close the connection.
Why use PreparedStatement?
It precompiles the query and binds parameters separately, which prevents SQL injection and is faster for repeated queries.
What is a thread? How do you create one?
A thread is a lightweight unit of execution. Create one by extending Thread or implementing Runnable and calling start().
What is the difference between == and equals()?
== compares references for objects. equals() compares content when overridden, as in String.
What is garbage collection?
Automatic memory management in which the JVM frees objects that are no longer referenced.
What is the difference between String, StringBuilder and StringBuffer?
String is immutable. StringBuilder is mutable and not thread-safe. StringBuffer is mutable and thread-safe.
What is a package?
A namespace that groups related classes and interfaces, such as java.util.
What is the use of the super keyword?
It refers to the parent class: to call its constructor, methods or fields.
Questions on your own Java project
- Which classes did you create and how are they related?
- Where did you use inheritance or interfaces?
- Show the JDBC connection code and explain each line
- How do you validate user input?
- Which layout or framework did you use for the UI: Swing, JavaFX, JSP, Spring?
FAQs
Is this useful for MSBTE Java Programming (JPR 314317)?
Yes. These questions cover the practical and oral topics of the K-scheme Java Programming course in the fourth semester.
Last reviewed: 2026-10-11. Always follow the format your own department gives you.