1.
a) Assign Object Reference Variable: Assigning an object reference variable means assigning
one object reference to another. It does not copy the object but refers to the same memory location.
Example: A a1 = new A(); A a2 = a1;
b) Object as a Parameter: Objects can be passed as parameters to methods. This allows sharing of
data between methods. Example: void display(A obj) { ... }
c) Returning Object: A method can return an object. It helps reuse objects or create new instances.
Example: A getObject() { return new A(); }
2. Constructor: A constructor initializes an object when it is created. It has the same name as the
class and no return type. Types: - Default Constructor - Parameterized Constructor - Copy
Constructor
3. Method Overloading: Method overloading means defining multiple methods with the same name
but different parameters. Example: void sum(int a, int b); void sum(double a, double b);
4. Array in Java: An array is a collection of elements of the same type stored in contiguous memory.
Example: int[] arr = {1, 2, 3, 4};
5. Method Overloading (Repeated): Same as Question 3.
6. Command-Line Arguments: Command-line arguments are values passed to the main method
when the program runs. Example: public class Demo { public static void main(String[] args) {
[Link](args[0]); } }
7. Streams in Java: A Stream represents input/output of data. Types: - Byte Stream
(FileInputStream, FileOutputStream) - Character Stream (FileReader, FileWriter)
8. this and static Keywords: ‘this’ refers to the current object. Example: this.x = x; ‘static’ is used for
class-level members shared by all objects. Example: static int count;
UNIT III
9. Inheritance: Inheritance allows one class to acquire properties of another. Types: Single, Multiple
(via interfaces), Multilevel, Hierarchical, Hybrid.
10. Java Programs: a) Single Inheritance: class A { void show(){} } class B extends A {}
b) Multiple Inheritance: Achieved using interfaces. interface A {} interface B {} class C implements
A,B {}
c) Multilevel Inheritance: class A {} class B extends A {} class C extends B {}
11. Polymorphism: Polymorphism means one interface, many forms. Types: Compile-time
(overloading) and Runtime (overriding).
12. Java Programs: a) Compile-time Polymorphism: Method Overloading b) Run-time
Polymorphism: Method Overriding
13. Exception Handling: Exception handling prevents abnormal termination of program. try – code
with risk catch – handles exception finally – always executes Example: try { int a=5/0; }
catch(Exception e){ [Link](e); } finally{ [Link]("Done"); }
14. Threading in Java: A thread is a lightweight process. Example: class A extends Thread { public
void run(){ [Link]("Thread Running"); } }
15. Superclass & Subclass: Superclass: base class; Subclass: derived class. Inheritance allows
code reusability by extending classes.
16. Access Modifiers: private – accessible within class protected – accessible within package and
subclass public – accessible everywhere Protected lies between private and public.