0% found this document useful (0 votes)
1 views12 pages

OOPS With Java Lab File

The document outlines a laboratory file for a B.Tech CSE course on Object Oriented Programming with Java, detailing ten practical exercises including Hello World, Class and Object, Constructor, Method Overloading, Inheritance, Method Overriding, Abstract Class, Interface, Exception Handling, and Multithreading. Each practical includes an aim, algorithm, sample code, and confirms successful execution of the program. The conclusion states that all practicals were performed and verified successfully.

Uploaded by

ajay0004161
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views12 pages

OOPS With Java Lab File

The document outlines a laboratory file for a B.Tech CSE course on Object Oriented Programming with Java, detailing ten practical exercises including Hello World, Class and Object, Constructor, Method Overloading, Inheritance, Method Overriding, Abstract Class, Interface, Exception Handling, and Multithreading. Each practical includes an aim, algorithm, sample code, and confirms successful execution of the program. The conclusion states that all practicals were performed and verified successfully.

Uploaded by

ajay0004161
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

OOPS with Java Lab File

[Link] CSE - Object Oriented Programming with Java Laboratory

Index
[Link]. Practical Name Date Signature
1 Java Hello World
Program
2 Class and Object
Program
3 Constructor
Program
4 Method Overloading
5 Inheritance
Program
6 Method Overriding
7 Abstract Class
Program
8 Interface Program
9 Exception Handling
Program
10 Multithreading
Program
Practical 1: Java Hello World Program
Aim: To study and implement Java Hello World Program.

Algorithm:
1. Start the program.
2. Write the Java code.
3. Compile the program.
4. Execute the program.
5. Display the output.
6. Stop the program.

class HelloWorld {
public static void main(String args[]) {
[Link]("Hello World");
}
}

Result: Program executed successfully.


Practical 2: Class and Object Program
Aim: To study and implement Class and Object Program.

Algorithm:
1. Start the program.
2. Write the Java code.
3. Compile the program.
4. Execute the program.
5. Display the output.
6. Stop the program.

class Student {
int id = 101;
String name = "Ajay";

void display() {
[Link](id + " " + name);
}

public static void main(String args[]) {


Student s = new Student();
[Link]();
}
}

Result: Program executed successfully.


Practical 3: Constructor Program
Aim: To study and implement Constructor Program.

Algorithm:
1. Start the program.
2. Write the Java code.
3. Compile the program.
4. Execute the program.
5. Display the output.
6. Stop the program.

class Test {
Test() {
[Link]("Constructor Called");
}

public static void main(String args[]) {


Test t = new Test();
}
}

Result: Program executed successfully.


Practical 4: Method Overloading
Aim: To study and implement Method Overloading.

Algorithm:
1. Start the program.
2. Write the Java code.
3. Compile the program.
4. Execute the program.
5. Display the output.
6. Stop the program.

class Add {
int sum(int a, int b) {
return a + b;
}

int sum(int a, int b, int c) {


return a + b + c;
}

public static void main(String args[]) {


Add obj = new Add();
[Link]([Link](10, 20));
[Link]([Link](10, 20, 30));
}
}

Result: Program executed successfully.


Practical 5: Inheritance Program
Aim: To study and implement Inheritance Program.

Algorithm:
1. Start the program.
2. Write the Java code.
3. Compile the program.
4. Execute the program.
5. Display the output.
6. Stop the program.

class Animal {
void eat() {
[Link]("Eating...");
}
}

class Dog extends Animal {


void bark() {
[Link]("Barking...");
}

public static void main(String args[]) {


Dog d = new Dog();
[Link]();
[Link]();
}
}

Result: Program executed successfully.


Practical 6: Method Overriding
Aim: To study and implement Method Overriding.

Algorithm:
1. Start the program.
2. Write the Java code.
3. Compile the program.
4. Execute the program.
5. Display the output.
6. Stop the program.

class Bank {
int getRateOfInterest() {
return 0;
}
}

class SBI extends Bank {


int getRateOfInterest() {
return 8;
}

public static void main(String args[]) {


SBI s = new SBI();
[Link]([Link]());
}
}

Result: Program executed successfully.


Practical 7: Abstract Class Program
Aim: To study and implement Abstract Class Program.

Algorithm:
1. Start the program.
2. Write the Java code.
3. Compile the program.
4. Execute the program.
5. Display the output.
6. Stop the program.

abstract class Shape {


abstract void draw();
}

class Circle extends Shape {


void draw() {
[Link]("Drawing Circle");
}

public static void main(String args[]) {


Shape s = new Circle();
[Link]();
}
}

Result: Program executed successfully.


Practical 8: Interface Program
Aim: To study and implement Interface Program.

Algorithm:
1. Start the program.
2. Write the Java code.
3. Compile the program.
4. Execute the program.
5. Display the output.
6. Stop the program.

interface Printable {
void print();
}

class A implements Printable {


public void print() {
[Link]("Hello");
}

public static void main(String args[]) {


A obj = new A();
[Link]();
}
}

Result: Program executed successfully.


Practical 9: Exception Handling Program
Aim: To study and implement Exception Handling Program.

Algorithm:
1. Start the program.
2. Write the Java code.
3. Compile the program.
4. Execute the program.
5. Display the output.
6. Stop the program.

class TestException {
public static void main(String args[]) {
try {
int data = 100 / 0;
}
catch(ArithmeticException e) {
[Link](e);
}

[Link]("Rest of the code");


}
}

Result: Program executed successfully.


Practical 10: Multithreading Program
Aim: To study and implement Multithreading Program.

Algorithm:
1. Start the program.
2. Write the Java code.
3. Compile the program.
4. Execute the program.
5. Display the output.
6. Stop the program.

class MyThread extends Thread {


public void run() {
[Link]("Thread is running");
}

public static void main(String args[]) {


MyThread t = new MyThread();
[Link]();
}
}

Result: Program executed successfully.


Conclusion
All OOPS with Java practicals were performed successfully and verified.

You might also like