0% found this document useful (0 votes)
0 views

DCE501_Java_LabManual

The document outlines the curriculum for Object Oriented Programming with Java for Diploma in Computer Engineering, detailing various practical experiments across five sets. Each practical focuses on different programming concepts such as installing JDK, using classes and objects, inheritance, method overriding, and exception handling. The document serves as a guide for students to complete their practical assignments and enhance their programming skills in Java.

Uploaded by

rajesh samata
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

DCE501_Java_LabManual

The document outlines the curriculum for Object Oriented Programming with Java for Diploma in Computer Engineering, detailing various practical experiments across five sets. Each practical focuses on different programming concepts such as installing JDK, using classes and objects, inheritance, method overriding, and exception handling. The document serves as a guide for students to complete their practical assignments and enhance their programming skills in Java.

Uploaded by

rajesh samata
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

NOBLE UNIVERSITY

FACULTY OF ENGINEERING & TECHNOLOGY


DEPARTMENT OF COMPUTER ENGINEERING

Object Oriented Programming


with Java
(DCE501)

Branch
Diploma Computer Engineering
Semester: 5th
NOBLE UNIVERSITY
FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF COMPUTER ENGINEERING

Enrollment No. -
Student Name: -

INDEX
Sr. List of Experiments Date Grade Sign
No.

Practical set-1
1 Install JDK, write a simple Hello World java program,
compilation, debugging, executing using java compiler
and interpreter.
2 Write a program to find maximum number from 3 number
numbers using conditional operator.

3 Write a program to print 1 to 10 prints in descending


(reverse)order using while loop.

4 Write a program to find number is prime or not.

5 Write a program to create 3 x 3 matrix using for loop.

6 Write a program to add two 3 x 3 Matrix.

7 Write a program to check number is odd or even.

8 Write a program to print sum of 1 t o10 number using do


while loop.

9 Write a program to print following series using while loop


1 11 21 . . . 91

10 Write a program to find factorial of 5.

11 Develop a Java program to find maximum and minimum


numbers from array elements.
Practical set-2
1 Develop a basic java program that demonstrates the use
of Class & Object.

2 Write a program in Java which has a class Rectangle


having two instance variables height and width. Initialize
the class using constructor. Find out area of rectangle (R
= l *b)
3 Write a program in Java demonstrate the use of “this”
keyword

4 Write a program in Java to demonstrate the use of “static”


keyword.

5 Write a program in Java to demonstrate the use of "final"


keyword.

6 Write a program in Java which has a class Shape having


2 overloaded methods area (float radius) and area (float
length, float width). Display the area of circle and
rectangle using overloaded methods.
7 Write a program in Java to demonstrate the constructor
overloading.

8 Write a program for the use of string class.

9 Write a program in Java to demonstrate use of Scanner


class.

Practical set-3
1 Write a program in Java to demonstrate single
inheritance.

2 Write a program in Java to demonstrate multilevel


inheritance.

3 Write a program in Java to demonstrate hierarchical


inheritance.

4 Write a program in Java to demonstrate or a use of


method overriding.

5 Write a program in Java which has a class Car having two


instance variables top Speed and name. Override to String
() method in Car class. Create 5 instances of Car class and
print the instances.
6 Write a program in Java to implement multiple
inheritance using interfaces.

7 Write a program in Java which has an abstract class Shape


having three subclasses: Tr-iangle, Rectangle, and Circle.
Define method area() in the abstract class Shape and
override area() method to calculate the area.
8 Write a program in Java to demonstrate use of final class.

9 Write a program in Java to demonstrate use of package.

Practical set-4
1 Write a program in Java to develop user defined
exception for 'Divide by Zero' error.

2 Write a program in Java to develop user defined


exception less than zero with user define class.

3 Write a program for the use of finally block.

4 Write a program that executes two threads. One thread


displays “Thread1” every 1000 milliseconds, and the
other displays “Thread2” every 2000 milliseconds. Create
the threads by extending the Thread class

Practical set-5
1 Develop programs to create, write, modify, read
operations on Text files.
FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Object Oriented Programming with Java

Practical Set - 1

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-1
Aim: - Install JDK, write a simple Hello World java program, compilation, debugging,
executing using java compiler and interpreter.

Step 1: Go to the Oracle site and open the Java SE download page.
Under the latest version of Java Platform, Standard Edition, click on the JDK
download button

Step 2: Next,
1. Accept License Agreement
Download latest Java JDK for your version(32 or 64 bit) of java for Windows.
Download latest Java JDK for your version(32 or 64 bit) of java for Windows.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Step 3: Once the download is complete, run the exe for install JDK. Click Next

Step 4: Once the installation is complete click Close

How to set Environment Variables in Java: Path and Classpath


• The PATH variable gives the location of executables like javac, java etc. It is possible
to run a program without specifying the PATH but you will need to give full path of
executable like C:\Program Files\Java\jdk1.8.0_131\bin\javac A.java instead of
simple javac A.java
• The CLASSPATH variable gives the location of the Library Files.
• let's look into the steps to set the PATH and CLASSPATH

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Step 1: Right Click on the My Computer and Select the properties

---

Step 2: Click on advanced system settings

Step 3: Click on Environment Variables

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Step 4: Click on new Button of User variables

Step 5: Type PATH in the Variable name.

Step 6: Copy the path of bin folder which is installed in JDK folder.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Step 7: Paste Path of bin folder in Variable value and click on OK Button.

Note: In case you already have a PATH variable created in your PC, then paste your path
separated with a semi-comma (;), edit the PATH variable to

PATH = <JDK installation directory>\bin;%PATH%;

Here, %PATH% appends the existing path variable to our new value

Step 8: You can follow a similar process to set CLASSPATH.

Note: In case you java installation does not work after installation, change classpath to

CLASSPATH = <JDK installation directory>\lib\tools.jar;

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Step 9: Click on OK button

Step 10 Go to command prompt and type javac commands.


If you see a screen like below, Java is installed.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Now Here your Hello World Program

class p1
{
public static void main(String s[])
{
System.out.println("Hello World!!");
}
}

Output: -

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-2
Aim: - Write a program to find maximum number from 3 number numbers using conditional
operator.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-3
Aim: - Write a program to print 1 to 10 prints in descending (reverse)order using while loop.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-4
Aim: - Write a program to find number is prime or not.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-5
Aim: - Write a program to create 3 x 3 matrix using for loop.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-6
Aim: - Write a program to add two 3 x 3 Matrix.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-7
Aim: - Write a program to check number is odd or even.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-8
Aim: - Write a program to print sum of 1 t o10 number using do while loop.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-9
Aim: - Write a program to print following series using while loop 1 11 21 . . . 91

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-10
Aim: - Write a program to find factorial of 5.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-11
Aim: - Develop a Java program to find maximum and minimum numbers from array
elements.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Object Oriented Programming with Java

Practical Set - 2

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-1
Aim: - Develop a basic java program that demonstrates the use of Class & Object.
Part-1

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Part-2

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-2
Aim: - Write a program in Java which has a class Rectangle having two instance variables
height and width. Initialize the class using constructor. Find out area of rectangle (R = l *b)

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-3
Aim: - Write a program in Java demonstrate the use of “this” keyword

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-4
Aim: - Write a program in Java to demonstrate the use of “static” keyword.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-5
Aim: - Write a program in Java to demonstrate the use of "final" keyword.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-6
Aim: - Write a program in Java which has a class Shape having 2 overloaded methods area
(float radius) and area (float length, float width). Display the area of circle and rectangle using
overloaded methods.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-7
Aim: - Write a program in Java to demonstrate the constructor overloading.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-8
Aim: - Write a program for the use of string class.
.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-9
Aim: - Write a program in Java to demonstrate use of Scanner class.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Object Oriented Programming with Java

Practical Set - 3

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-1
Aim: - Write a program in Java to demonstrate single inheritance.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-2
Aim: - Write a program in Java to demonstrate multilevel inheritance.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-3
Aim: - Write a program in Java to demonstrate hierarchical inheritance.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-4
Aim: - Write a program in Java to demonstrate or a use of method overriding.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-5
Aim: - Write a program in Java which has a class Car having two instance variables top Speed
and name. Override to String () method in Car class. Create 5 instances of Car class and print
the instances.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-6
Aim: - Write a program in Java to implement multiple inheritance using interfaces.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-7
Aim: - Write a program in Java which has an abstract class Shape having three subclasses:
Tr-iangle, Rectangle, and Circle. Define method area() in the abstract class Shape and
override area() method to calculate the area.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-8
Aim: - Write a program in Java to demonstrate use of final class.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-9
Aim: - Write a program in Java to demonstrate use of package.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Object Oriented Programming with Java

Practical Set - 4

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-1
Aim: - Write a program in Java to develop user defined exception for 'Divide by Zero' error.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-2
Aim: - Write a program in Java to develop user defined exception less than zero with user
define class.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-3
Aim: - Write a program for the use of finally block.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-4
Aim: - Write a program that executes two threads. One thread displays “Thread1” every 1000
milliseconds, and the other displays “Thread2” every 2000 milliseconds. Create the threads by
extending the Thread class

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Object Oriented Programming with Java

Practical Set - 5

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Practical-1
Aim: - Develop programs to create, write, modify, read operations on Text files.

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Subject : Object Oriented Programming with Java


FACULTY OF ENGINEERING & TECHNOLOGY
DEPARTMENT OF CE/CSE/IT

Subject : Object Oriented Programming with Java

You might also like