Java 2m - 241125 - 150235
Java 2m - 241125 - 150235
10. **Inspect the events which will be generated if we close an applet’s window**
When an applet’s window is closed, a WindowEvent is generated, specifically the
`windowClosing` event in the WindowListener interface.
5th unit
3rd unit
• Exceptions occur due to unexpected events like invalid input or resource issues.
• They happen when something goes wrong during program execution.
7. Advantages of Multithreading:
8.Use of Multithreading:
• Used for tasks like downloading files or handling user input simultaneously.
• It is helpful for making programs responsive and efficient.
• The wait() method pauses the current thread until another thread signals it to
continue.
• It helps manage synchronization between threads.
2nd unit
2.Usage of Inheritance:
• Function overloading occurs when multiple methods have the same name but
different parameters.
• It improves code readability and allows flexibility in method calls.
6.Interface in Java:
• An interface is a blueprint of a class containing abstract methods and constants.
• It is used to achieve abstraction and multiple inheritance.
7.Final Variable:
• An interface contains only abstract methods and constants, while a class has
fields, constructors, and concrete methods.
• Interfaces are used for abstraction and implementing multiple inheritance.
1st unit
1.Functions of JVM:
• The JVM (Java Virtual Machine) loads, verifies, and executes Java bytecode.
• It provides platform independence and manages memory using the garbage collector.
3.Anonymous Object:
4.Equals() vs == in Java:
• equals() compares object content, while == checks if two references point to the
same object.
int num = 16; int sqrt = (int) Math.sqrt(num); if (sqrt * sqrt == num)
System.out.println("Perfect Square"); else System.out.println("Not a Perfect
Square");
• Instance variables belong to an object and are declared inside a class but
outside methods.
• Constructors initialize objects and have no return type, while methods perform
tasks and can return values.