JAVA FINAL SEM EXAM - UNIT WISE IMPORTANT
ANSWERS
UNIT 1 – Fundamentals of Java & OOPs
Q. Explain Procedural Programming vs Object-Oriented Programming
Procedural Programming is based on functions and follows top-down approach. Object-Oriented Programming is
based on objects and follows bottom-up approach. OOP provides inheritance, polymorphism, abstraction and
encapsulation.
Q. Features of Java
Java is Simple, Object-Oriented, Platform Independent, Portable, Secure, Robust, Multithreaded, Scalable and
High Performance.
Q. Explain JVM
JVM stands for Java Virtual Machine. It converts bytecode into machine code and makes Java platform
independent.
Q. Explain OOP Concepts
Important OOP concepts are Class, Object, Inheritance, Polymorphism, Abstraction and Encapsulation.
Q. Program for Class and Object
class Student {
int roll;
String name;
void display() {
[Link](roll + " " + name);
}
public static void main(String args[]) {
Student s1 = new Student();
[Link] = 1;
[Link] = "Nikhil";
[Link]();
}
}
UNIT 2 – Classes and Objects
Q. Access Modifiers
Java provides four access modifiers: public, private, protected and default.
Q. Static and Non-Static Members
Static members belong to class while non-static members belong to object.
Q. Constructors
Constructors are special methods used to initialize objects. Types are default and parameterized constructor.
Q. Method Overloading
Method overloading means same method name with different parameters.
UNIT 3 – Inheritance, Interfaces and Packages
Q. Inheritance
Inheritance is the process of acquiring properties of one class into another class.
Q. Types of Inheritance
Single, Multilevel, Hierarchical, Hybrid and Multiple inheritance.
Q. Method Overriding
Method overriding means redefining parent class method in child class.
Q. Interface
Interface is a collection of abstract methods used to achieve abstraction and multiple inheritance.
UNIT 4 – Exception Handling and Multithreading
Q. Error vs Exception
Errors are irrecoverable while exceptions are recoverable.
Q. Try-Catch-Finally
Try block contains risky code, catch handles exception and finally block always executes.
Q. Throw and Throws
throw keyword explicitly throws exception while throws declares exceptions.
Q. Multithreading
Multithreading allows multiple threads to execute simultaneously.
UNIT 5 – GUI Programming using Swing
Q. Swing Containers
Important Swing containers are JFrame, JPanel and JWindow.
Q. Swing Components
Common Swing components are JLabel, JButton, JTextField, JCheckBox and JComboBox.
Q. Event Handling
Event handling controls events generated through user interaction.
Q. AWT vs Swing
Swing is lightweight and platform independent while AWT is heavyweight.