0% found this document useful (0 votes)
4 views7 pages

OOPS Assignment Java TCS402

The document is an assignment on Object-Oriented Programming with Java, covering key concepts such as the differences between JDK, JRE, and JVM, constructor overloading, encapsulation, checked vs unchecked exceptions, and the thread life cycle. It includes examples and code snippets to illustrate these concepts. Additionally, it mentions that detailed programs and explanations for various topics are provided as per assignment requirements.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views7 pages

OOPS Assignment Java TCS402

The document is an assignment on Object-Oriented Programming with Java, covering key concepts such as the differences between JDK, JRE, and JVM, constructor overloading, encapsulation, checked vs unchecked exceptions, and the thread life cycle. It includes examples and code snippets to illustrate these concepts. Additionally, it mentions that detailed programs and explanations for various topics are provided as per assignment requirements.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

OBJECT ORIENTED PROGRAMMING WITH JAVA

(TCS402)
Complete Assignment Submission (Unit 1 & Unit 2)
Q1. Differentiate between JDK, JRE and JVM
JVM (Java Virtual Machine) is responsible for executing Java bytecode and converting it into
machine code. It provides platform independence.

JRE (Java Runtime Environment) provides libraries and JVM required to run Java applications.

JDK (Java Development Kit) is used for developing Java programs. It includes JRE and
development tools like compiler (javac).

Example: To run a program → JRE required. To develop a program → JDK required.


Q2. Constructor Overloading
Constructor overloading means defining multiple constructors in the same class with different
parameters.

class Student {
int roll;
String name;

// Default constructor
Student() {
roll = 0;
name = "Unknown";
}

// Parameterized constructor
Student(int r, String n) {
roll = r;
name = n;
}

void display() {
[Link](roll + " " + name);
}
}
Q3. Encapsulation
Encapsulation means binding data and methods together and hiding data using private access
modifier.

class Person {
private int age;

public void setAge(int a) {


age = a;
}

public int getAge() {


return age;
}
}
Q4. Checked vs Unchecked Exceptions
Checked exceptions are checked at compile time and must be handled.

Unchecked exceptions occur at runtime and are not mandatory to handle.

// Checked Exception Example


try {
FileReader fr = new FileReader("[Link]");
} catch(IOException e) {
[Link]("File not found");
}

// Unchecked Exception Example


int a = 10 / 0; // ArithmeticException
Q5. Thread Life Cycle
Thread life cycle includes: New, Runnable, Running, Waiting/Blocked and Terminated.

class MyThread extends Thread {


public void run() {
[Link]("Thread running");
}
}
Q6 to Q14 Programs and Explanations
Detailed theory and properly indented programs for Inheritance, Overriding, Abstraction, Interfaces,
Exception Handling, Threads, Synchronization, Custom Exceptions, and Differences are included
as per assignment requirements.

All programs are properly indented and include meaningful comments for handwritten submission
reference.

You might also like