CLASSES
INHERITANCE & INTERFACE
EXCEPTION HANDLING
FILE INPUT/OUTPUT
100

What is a class in Java?

A blueprint or template used to create objects.

100

What keyword is used for inheritance?

extends

100

What is an exception?

An error that occurs during program execution.

100

What class is used to read files?

FileReader

200

What is the default value of an uninitialized int?

Zero or 0

200

Can a class implement multiple interfaces?

Yes

200

What keyword is used to handle exceptions?

try-catch

200

What package is used for file handling?

import java.io.*;

300

What is method overloading?

Defining multiple methods with the same name but different parameters.

300

What is the difference between extends and implements?

extends is for classes; implements is for interfaces.

300

What happens if an exception is not handled?

Program terminates.

300

What is IOException?

Exception for input/output errors.

400

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)

400

You are building a game with characters (Warrior, Mage, Archer) that share common properties. What concept should you use?

Inheritance

400

You want to prevent your program from crashing when users input invalid data. What should you use?

try-catch

400

You need to read a large text file efficiently line by line. What should you use?

BufferedReader

500

You want objects to automatically receive values when they are created (e.g., student name and ID). What should you use?

Constructor

500

You want unrelated classes (Printer, Scanner) to follow the same method structure. What should you use?

Interface

500

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

500

You want to save user data into a file efficiently. What should you use?

BufferedWriter or FileWriter

M
e
n
u