■ Java Exam Creative Notebook
Complete Q&A; • MCQs • Diagrams • University & Company Questions
■ Section 1: 1-Mark Questions
Q. What is the purpose of the final keyword when applied to
variables?
➡■ It makes the variable constant (value cannot be changed once assigned).
Q. What is the purpose of the javap tool in Java?
➡■ It is a disassembler tool that shows bytecode and method/field details of compiled
.class files.
Q. How is a 1D array declared in Java?
➡■ Syntax: int arr[] = new int[5];
Q. What is the Object class in Java?
➡■ It is the parent (superclass) of all classes in Java. Every class directly or indirectly
inherits it.
Q. Name any two GUI components used in Swing.
➡■ JButton, JTextField
■ FileReader vs FileWriter
FileReader FileWriter
Reads data from files. Writes data to files.
Character-based input. Character-based output.
Returns int (character code). Writes single char/array/string.
Example: FileReader fr=new FileReader("[Link]"); Example: FileWriter fw=new FileWriter("[Link]");
■ Example Program: Inheritance with super Keyword
class Animal { Animal() { [Link]("Animal created"); }
} class Dog extends Animal { Dog() { super(); // Calls parent
constructor [Link]("Dog created"); } } public class
Test { public static void main(String[] args) { Dog d = new Dog();
} }