What is a class in Java?
A blueprint or template used to create objects.
What keyword is used for inheritance?
extends
What is an exception?
An error that occurs during program execution.
What class is used to read files?
FileReader
What is the default value of an uninitialized int?
Zero or 0
Can a class implement multiple interfaces?
Yes
What keyword is used to handle exceptions?
try-catch
What is method overloading?
Defining multiple methods with the same name but different parameters.
What is the difference between extends and implements?
extends is for classes; implements is for interfaces.
What happens if an exception is not handled?
Program terminates.
What is IOException?
Exception for input/output errors.
You are designing a bank system where account details should not be directly accessed by other classes. What should you use?
Encapsulation (private variables + getters/setters)
You are building a game with characters (Warrior, Mage, Archer) that share common properties. What concept should you use?
Inheritance
You want to prevent your program from crashing when users input invalid data. What should you use?
try-catch
You need to read a large text file efficiently line by line. What should you use?
BufferedReader
You want objects to automatically receive values when they are created (e.g., student name and ID). What should you use?
Constructor
You want unrelated classes (Printer, Scanner) to follow the same method structure. What should you use?
Interface
You are working with a database connection, and it must always be closed even if an error happens during execution. What should you use?
finally block
You want to save user data into a file efficiently. What should you use?
BufferedWriter or FileWriter