OBJECT ORIENTED PROGRAMMING WITH JAVA - ASSIGNMENT
SECTION A
1(a) Output: 30
1(b) Java does not support multiple inheritance via classes but supports it using interfaces.
1(c) Overloading vs Overriding: Overloading is compile-time, overriding is runtime polymorphism.
1(d) Thread vs Runnable: Thread is class-based, Runnable is interface-based.
1(e) Static methods can be called without object.
1(f) Functional interface has only one abstract method.
SECTION B
2(a) Bank example implemented using abstract class and subclasses.
abstract class Bank {
abstract int getBalance();
}
2(b) Thread lifecycle: New → Runnable → Running → Waiting → Terminated
2(c) Race condition occurs due to lack of synchronization.
2(d) Multiple inheritance not allowed using classes.
SECTION C
3(a) Shape inheritance example implemented.
3(b) Output: Concrete method of parent class
[Link]() delays execution.
SECTION D
4(a) Concepts: Encapsulation, Polymorphism, Abstraction
4(b) Problem: Race condition. Solution: Synchronization