AOOP-4340701-Lab Manual
AOOP-4340701-Lab Manual
Laboratory Manual
(Advanced Object-Oriented
Programming)
(4340701)
Institute’s Vision:
Institute’s Mission:
Department’s Vision:
Department’s Mission:
GOVERNMENT POLYTECHNIC JAMNAGAR
Certificate
Place:…………………..
Date: …………………..
By using this lab manual, students can read procedure one day in advance to actual performance day
of practical experiment which generates interest and also, they can have idea of judgement of magnitude prior
to performance. This in turn enhances predetermined outcomes amongst students. Each and every
Experiment
/Practical in this manual begins by competency, industry relevant skills, course outcomes as well as practical
outcomes which serve as a key role for doing the practical. The students will also have a clear idea of safety
and necessary precautions to be taken while performing experiment.
This manual also provides guidelines to lecturers to facilitate student-centered lab activities for each
practical/experiment by arranging and managing necessary resources in order that the students follow the
procedures with required safety and necessary precautions to achieve outcomes. It also gives an idea that how
students will be assessed by providing Rubrics.
Although we try our level best to design this lab manual, but always there are chances of improvement.
We welcome any suggestions for improvement.
Programme Outcomes (POs) to be achieved through Practical of this Course
Following programme outcomes are expected to be achieved through the practical of the
course:
1. Basic and Discipline specific knowledge: Apply knowledge of basic mathematics, science and
engineering fundamentals and engineering specialization to solve the engineering problems.
2. Problem analysis: Identify and analyze well-defined engineering problems using codified standard
methods
3. Design/ development of solutions Design solutions for well-defined technical problems and assist
with the design of systems components or processes to meet specified needs
4. Engineering Tools, Experimentation and Testing: Apply modern engineering tools and
appropriate technique to conduct standard tests and measurements
7. Life-long learning: Ability to analyze individual needs and engage in updating in the context of
technological changes.
Practical Outcome - Course Outcome matrix
Course Outcomes (COs):
The following industry relevant skills of the competency “Develop java application using object-
oriented approach.” are expected to be developed in the student by undertaking the practical of this
laboratory manual.
Practical
Outcome / Date Marks
Sr Page Sign
Title of (25)
experiment
1. Install JDK, write a simple “Hello World” or
similar java program, compilation, debugging,
executing using java compiler and interpreter.
9.
Write a program in Java to demonstrate the
use of “static” keyword.
14.
Write a program in Java to demonstrate single
inheritance
15.
Write a program in Java to demonstrate
multilevel inheritance
16.
Write a program in Java to demonstrate
hierarchical inheritance.
17.
Write a program in Java to demonstrate
method overriding.
18.
*Write a program in Java which has a class Car
having two instance variables topSpeed and
name. Override toString() method in Car class.
Create 5 instances of Car class and print the
instances.
19.
Write a program in Java to implement multiple
inheritance using interfaces.
20.
*Write a program in Java which has an
abstract class Shape having three subclasses:
Triangle, Rectangle, and Circle. Define
method area() in the abstract class Shape and
override area() method to calculate the area.
21.
Write a program in Java to demonstrate use of
final class.
22.
Write a program in Java to demonstrate use of
package.
23.
Write a program in Java to develop user
defined exception for 'Divide by Zero' error.
24.
*Write a program in Java to develop Banking
Application in which user deposits the amount
Rs 25000 and then start withdrawing of Rs
20000, Rs 4000 and it throws exception "Not
Sufficient Fund" when user withdraws Rs.
2000 thereafter.
25.
*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
26.
Write a program that executes two threads.
One thread will print the even numbers and
another thread will print odd numbers from 1
to 200.
27.
*Write a program in Java to perform read and
write operations on a Text file.
28.
Write a program in Java to demonstrate use of
List.
1) Create ArrayList and add weekdays (in
string form)
2) Create LinkedList and add months (in string
form)
Display both List.
29.
Write a program in Java to create a new
HashSet, add colors(in string form) and iterate
through all elements using for-each loop to
display the collection.
30.
*Write a Java program to create a new
HashMap, add 5 students’ data (enrolment no
and name). retrieve and display the student’s
name from HashMap using enrolment no.
Advanced Object-Oriented Programming (4340701)
Date: ……………
Practical No: 1: Install JDK, write a simple “Hello World” or similar java program, compilation,
debugging, executing using java compiler and interpreter.
A. Objective:
E. Practical Outcome(PRo)
Install JDK, write a simple “Hello World” or similar java program, compilation,
debugging, executing using java compiler and interpreter.
G. Prerequisite Theory:
● JDK Installation
● Java compiler Path configuration
● Install Text Editor
1|Page
Advanced Object-Oriented Programming (4340701)
1. Go to "System Properties" (Can be found on Control Panel > System and Security > System
> Advanced System Settings)
2. Click on the "Environment variables" button under the "Advanced" tab
3. Then, select the "Path" variable in System variables and click on the "Edit" button
4. Click on the "New" button and add the path where Java is installed, followed by \bin. By
default, Java is installed in C:\Program Files\Java\jdk-11.0.1 (If nothing else was specified
when you installed it). In that case, You will have to add a new path with: C:\Program
Files\Java\jdk-11.0.1\bin
Then, click "OK", and save the settings
5. At last, open Command Prompt (cmd.exe) and type java -version to see if Java is running
on your machine
Step 1
Step 2
2|Page
Advanced Object-Oriented Programming (4340701)
Step 3
Step 4
3|Page
Advanced Object-Oriented Programming (4340701)
Step 5
If Java was successfully installed, you will see something like this (depending on version):
Main.java:-
public class Main {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification Quantity
No.
/Components/Trainer kit
1 Hardware: Computer System Computer (i3-i5 preferable),RAM Asper
mm1mum 2 GB and onwards batch size
4|Page
Advanced Object-Oriented Programming (4340701)
………………………………………………………………..………………………………………………………………..
………………………………………………………………………………………………………………………………..…
……………………………………………………………………………………………………………………………..……
…………………………………………………………………………………………………………………………..………
………………………………………………………………………………………………………………………..…………
……………………………………………………………………………………………………………………..……………
…………………………………………………………………………………………………………………..………………
………………………………………………………………………………………………………………..…………………
……………………………………………………………………………………………………………..……………………
…………………………………………………………………………………………………………..………………………
………………………………………………………………………………………………………..…………………………
……………………………………………………………………………………………………..……………………………
…………………………………………………………………………………………………..………………………………
………………………………………………………………………………………………..…………………………………
……………………………………………………………………………………………..……………………………………
…………………………………………………………………………………………..………………………………………
………………………………………………………………………………………..…………………………………………
……………………………………………………………………………………..……………………………………………
…………………………………………………………………………………..………………………………………………
………………………………………………………………………………..…………………………………………………
……………………………………………………………………………..……………………………………………………
…………………………………………………………………………..………………………………………………………
………………………………………………………………………..…………………………………………………………
……………………………………………………………………..……………………………………………………………
…………………………………………………………………..………………………………………………………………
………………………………………………………………..…………………………………………………………………
……………………………………………………………..……………………………………………………………………
…………………………………………………………..………………………………………………………………………
………………………………………………………..…………………………………………………………………………
……………………………………………………..……………………………………………………………………………
…………………………………………………..………………………………………………………………………………
………………………………………………..…………………………………………………………………………………
……………………………………………..……………………………………………………………………………………
…………………………………………..………………………………………………………………………………………
………………………………………..…………………………………………………………………………………………
……………………………………..……………………………………………………………………………………………
5|Page
Advanced Object-Oriented Programming (4340701)
……………………………………..……………………………………………………………………………………………
……………………………………..……………………………………………………………………………………………
……………………………………..……………………………………………………………………………………………
……………………………………..……………………………………………………………………………………………
K. Input-Output :
6|Page
Advanced Object-Oriented Programming (4340701)
4. https://www.youtube.com/watch?v=e7DXhdCsSnw
N. Assessment-Rubrics
Performance Indicators Weightage
Process related (15 Marks) 70%
1. Logic formation 30%
2. Debugging ability 30%
3. Follow ethical practices 10%
Product related (10 Marks) 30%
4. Expected output 10%
5. Timely Submission of report 10%
7|Page
Advanced Object-Oriented Programming (4340701)
8|Page
Advanced Object-Oriented Programming (4340701)
9|Page
Advanced Object-Oriented Programming (4340701)
10 | P a g e
Advanced Object-Oriented Programming (4340701)
11 | P a g e
Advanced Object-Oriented Programming (4340701)
Date: ……………
Practical No: 2.
A. Objective:
Write a program in Java to find maximum of three numbers using conditional operator.
Write a program in Java to find maximum of three numbers using conditional operator.
G. Prerequisite Theory:
In Java, control structures are used to control the flow of execution in a program. There are
three main types of control structures in Java: selection statements, iteration statements, and
jump statements.
12 | P a g e
Advanced Object-Oriented Programming (4340701)
Selection statements:
Selection statements are used to select one or more statements to execute based on the
result of a boolean expression. In Java, the two main types of selection statements are if-else
and switch statements.
if-else statement: It executes a block of code if a boolean expression is true, and executes an
alternate block of code if the expression is false. Here's an example:
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification Quantity
No.
/Components/Trainer kit
1 Hardware: Computer System Computer (i3-i5 preferable),RAM Asper
mm1mum 2 GB and onwards batch size
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
13 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
14 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..……………………………………………………………………….…………
………………………………………………………………………………………………………………………………………………..
K. Input-Output:
15 | P a g e
Advanced Object-Oriented Programming (4340701)
M. References / Suggestions
https://www.w3schools.com/java/default.asp
https://www.javatpoint.com/java-tutorial
N. Assessment-Rubrics
16 | P a g e
Advanced Object-Oriented Programming (4340701)
17 | P a g e
Advanced Object-Oriented Programming (4340701)
18 | P a g e
Advanced Object-Oriented Programming (4340701)
19 | P a g e
Advanced Object-Oriented Programming (4340701)
20 | P a g e
Advanced Object-Oriented Programming (4340701)
Date: ……………
Practical No: 3.
A. Objective:
Write a program in Java to reverse the digits of a number using while loop
Write a program in Java to reverse the digits of a number using while loop
G. Prerequisite Theory:
In Java, loops are used to execute a block of code repeatedly until a certain condition is met.
There are three types of loops in Java: for loop, while loop, and do-while loop. Here's a brief
overview of each type of loop:
21 | P a g e
Advanced Object-Oriented Programming (4340701)
for loop: This loop is used to execute a block of code a fixed number of times. The syntax of a
for loop is as follows:
while (condition) {
// block of code to be executed
}
In this syntax, condition is a boolean expression that is evaluated before each iteration of the
loop.
do-while loop: This loop is similar to the while loop, except that the block of code is executed
at least once, even if the condition is initially false. The syntax of a do-while loop is as follows:
do {
// block of code to be executed
} while (condition);
In this syntax, condition is a boolean expression that is evaluated after each iteration of the
loop.
H. Resources/Equipment Required
22 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
23 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..……………………….…………………………………………………………
……………………………………………..
K. Input-Output:
24 | P a g e
Advanced Object-Oriented Programming (4340701)
Which of the following loops in Java is used to iterate over a fixed set of values or to
execute a block of code a fixed number of times?
a) for loop
b) while loop
c) do-while loop
M. References / Suggestions
https://www.w3schools.com/java/default.asp
https://www.javatpoint.com/java-tutorial
25 | P a g e
Advanced Object-Oriented Programming (4340701)
N. Assessment-Rubrics
26 | P a g e
Advanced Object-Oriented Programming (4340701)
27 | P a g e
Advanced Object-Oriented Programming (4340701)
28 | P a g e
Advanced Object-Oriented Programming (4340701)
29 | P a g e
Advanced Object-Oriented Programming (4340701)
30 | P a g e
Advanced Object-Oriented Programming (4340701)
Date: ……………
Practical No: 4.
A. Objective:
G. Prerequisite Theory:
31 | P a g e
Advanced Object-Oriented Programming (4340701)
In this example, arr is a 2D array with 3 rows and 4 columns. To access a specific element in
the array, you need to specify the row and column index. Here's an example of how to assign
a value to an element in the array:
arr[0][0] = 1;
This assigns the value 1 to the element in the first row and first column of the array.
You can also initialize a 2D array with values at the time of declaration. Here's an example:
In this example, arr is a 2D array with 3 rows and 3 columns. The values in the array are
initialized to the values specified in the curly braces.
To iterate over a 2D array, you can use nested loops. Here's an example of how to iterate over
the elements of a 2D array and print their values:
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification Quantity
No.
/Components/Trainer kit
1 Hardware: Computer System Computer (i3-i5 preferable),RAM Asper
mm1mum 2 GB and onwards batch size
32 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
33 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………………………………
……………………………………………..
K. Input-Output:
34 | P a g e
Advanced Object-Oriented Programming (4340701)
M. References / Suggestions
https://www.w3schools.com/java/default.asp
https://www.javatpoint.com/java-tutorial
35 | P a g e
Advanced Object-Oriented Programming (4340701)
N. Assessment-Rubrics
36 | P a g e
Advanced Object-Oriented Programming (4340701)
37 | P a g e
Advanced Object-Oriented Programming (4340701)
38 | P a g e
Advanced Object-Oriented Programming (4340701)
39 | P a g e
Advanced Object-Oriented Programming (4340701)
40 | P a g e
Advanced Object-Oriented Programming (4340701)
Date: ……………
Practical No: 5.
A. Objective:
G. Prerequisite Theory:
41 | P a g e
Advanced Object-Oriented Programming (4340701)
A prime number is a positive integer greater than 1 that has no positive integer divisors
other than 1 and itself. In other words, a prime number is a number that is only divisible by
1 and itself.
For example, 2, 3, 5, 7, 11, 13, 17, 19, 23, and 29 are all prime numbers.
To check if a number is prime, we can use a simple algorithm that involves dividing the
number by all integers from 2 to its square root. If the number is not divisible by any of
these integers, then it is prime. Otherwise, it is composite.
H. Resources/Equipment Required
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
42 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
43 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………………………………
……………………………………………..
K. Input-Output:
44 | P a g e
Advanced Object-Oriented Programming (4340701)
M. References / Suggestions
https://www.w3schools.com/java/default.asp
https://www.javatpoint.com/java-tutorial
N. Assessment-Rubrics
45 | P a g e
Advanced Object-Oriented Programming (4340701)
46 | P a g e
Advanced Object-Oriented Programming (4340701)
47 | P a g e
Advanced Object-Oriented Programming (4340701)
48 | P a g e
Advanced Object-Oriented Programming (4340701)
49 | P a g e
Advanced Object-Oriented Programming (4340701)
Date: ……………
Practical No: 6.
A. Objective:
Write a program in Java which has a class Student having two instance variables
enrollmentNo and name. Create 3 objects of Student class in main method and display
student’s name.
PO7: Life-long learning: Ability to analyze individual needs and engage in updating
in the context of technological changes in field of engineering.
CO2: Use object oriented programming concepts to solve real world problems.
Write a program in Java which has a class Student having two instance variables enrollmentNo
and name. Create 3 objects of Student class in main method and display student’s name.
50 | P a g e
Advanced Object-Oriented Programming (4340701)
G. Prerequisite Theory:
In Java, a class is a blueprint or template for creating objects. It defines the attributes and
behaviors of an object, and provides a way to create multiple objects of the same type.
Here is an example of a simple Java class:
51 | P a g e
Advanced Object-Oriented Programming (4340701)
To create an object of this class, you can use the new keyword followed by the class name and
the constructor arguments:
This creates a new Car object with the make "Toyota", model "Camry", and year 2021.
You can then call the object's methods using the dot notation:
myCar.start();
myCar.stop();
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification Quantity
No.
/Components/Trainer kit
1 Hardware: Computer System Computer (i3-i5 preferable),RAM Asper
mm1mum 2 GB and onwards batch size
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
52 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
53 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………………………………
……………………………………………..
K. Input-Output:
54 | P a g e
Advanced Object-Oriented Programming (4340701)
M. References / Suggestions
https://www.w3schools.com/java/default.asp
https://www.javatpoint.com/java-tutorial
N. Assessment-Rubrics
55 | P a g e
Advanced Object-Oriented Programming (4340701)
56 | P a g e
Advanced Object-Oriented Programming (4340701)
57 | P a g e
Advanced Object-Oriented Programming (4340701)
58 | P a g e
Advanced Object-Oriented Programming (4340701)
59 | P a g e
Advanced Object-Oriented Programming (4340701)
Date: ……………
Practical No: 7.
A. Objective:
*Write a program in Java which has a class Rectangle having two instance variables height
and weight. Initialize the class using constructor.
CO2: Use object oriented programming concepts to solve real world problems.
*Write a program in Java which has a class Rectangle having two instance variables height
and weight. Initialize the class using constructor.
G. Prerequisite Theory:
60 | P a g e
Advanced Object-Oriented Programming (4340701)
In this example, the Person class has a constructor that takes two parameters: name and age.
The constructor initializes the instance variables name and age with the values passed as
arguments.
To create a new Person object using the constructor, you can use the new keyword followed
by the class name and the constructor arguments.
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification Quantity
No.
/Components/Trainer kit
1 Hardware: Computer System Computer (i3-i5 preferable),RAM Asper
mm1mum 2 GB and onwards batch size
61 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
62 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………………………………
……………………………………………..
K. Input-Output:
63 | P a g e
Advanced Object-Oriented Programming (4340701)
M. References / Suggestions
https://www.w3schools.com/java/default.asp
https://www.javatpoint.com/java-tutorial
N. Assessment-Rubrics
64 | P a g e
Advanced Object-Oriented Programming (4340701)
65 | P a g e
Advanced Object-Oriented Programming (4340701)
66 | P a g e
Advanced Object-Oriented Programming (4340701)
67 | P a g e
Advanced Object-Oriented Programming (4340701)
68 | P a g e
Advanced Object-Oriented Programming (4340701)
Date: ……………
Practical No: 8.
A. Objective:
CO2: Use object oriented programming concepts to solve real world problems.
G. Prerequisite Theory:
In Java, "this" is a keyword that refers to the current object instance. It can be used inside a
class to refer to the object on which a method or constructor is being called.
69 | P a g e
Advanced Object-Oriented Programming (4340701)
public Rectangle() {
this(0, 0); // calls the Rectangle(int, int) constructor with arguments 0 and 0
}
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification Quantity
No.
/Components/Trainer kit
1 Hardware: Computer System Computer (i3-i5 preferable),RAM Asper
mm1mum 2 GB and onwards batch size
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
70 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
71 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………………………………
……………………………………………..
K. Input-Output:
72 | P a g e
Advanced Object-Oriented Programming (4340701)
M. References / Suggestions
https://www.w3schools.com/java/default.asp
https://www.javatpoint.com/java-tutorial
N. Assessment-Rubrics
73 | P a g e
Advanced Object-Oriented Programming (4340701)
74 | P a g e
Advanced Object-Oriented Programming (4340701)
75 | P a g e
Advanced Object-Oriented Programming (4340701)
76 | P a g e
Advanced Object-Oriented Programming (4340701)
77 | P a g e
Advanced Object-Oriented Programming (4340701)
Date: ……………
Practical No: 9.
A. Objective:
CO2: Use object oriented programming concepts to solve real world problems.
G. Prerequisite Theory:
In Java, the "static" keyword is used to create variables and methods that belong to the class
itself, rather than to an instance of the class. Here are some key points related to the "static"
keyword in Java:
78 | P a g e
Advanced Object-Oriented Programming (4340701)
Static variables: A static variable is a variable that is shared by all instances of a class. It is
created only once when the class is loaded into memory, and all instances of the class share
the same copy of the variable. To declare a static variable, use the "static" keyword before the
variable type. For example:
Static methods: A static method is a method that belongs to the class itself, rather than to an
instance of the class. It can be called using the class name, without creating an instance of the
class. To declare a static method, use the "static" keyword before the return type. For
example:
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification Quantity
No.
/Components/Trainer kit
1 Hardware: Computer System Computer (i3-i5 preferable),RAM Asper
mm1mum 2 GB and onwards batch size
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
79 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
80 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………………………………
……………………………………………..
K. Input-Output:
81 | P a g e
Advanced Object-Oriented Programming (4340701)
M. References / Suggestions
https://www.w3schools.com/java/default.asp
https://www.javatpoint.com/java-tutorial
N. Assessment-Rubrics
82 | P a g e
Advanced Object-Oriented Programming (4340701)
83 | P a g e
Advanced Object-Oriented Programming (4340701)
84 | P a g e
Advanced Object-Oriented Programming (4340701)
85 | P a g e
Advanced Object-Oriented Programming (4340701)
86 | P a g e
Advanced Object-Oriented Programming (4340701)
Date: ……………
Practical No: 10.
A. Objective:
CO2: Use object oriented programming concepts to solve real world problems.
G. Prerequisite Theory:
In Java, the "final" keyword is used to create constants, prevent method or class overriding,
and to create immutable objects. Here are some key points related to the "final" keyword in
Java:
87 | P a g e
Advanced Object-Oriented Programming (4340701)
Final variables: A final variable is a variable that cannot be changed once it has been
initialized. It is typically used to create constants, such as PI or VERSION_NUMBER. To declare
a final variable, use the "final" keyword before the variable type. For example:
Final classes: A final class is a class that cannot be subclassed. It is typically used to prevent
others from extending a class and modifying its behavior. To declare a final class, use the
"final" keyword before the class name. For example:
H. Resources/Equipment Required
88 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
89 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………………………………
……………………………………………..
K. Input-Output:
90 | P a g e
Advanced Object-Oriented Programming (4340701)
M. References / Suggestions
https://www.w3schools.com/java/default.asp
https://www.javatpoint.com/java-tutorial
N. Assessment-Rubrics
91 | P a g e
Advanced Object-Oriented Programming (4340701)
92 | P a g e
Advanced Object-Oriented Programming (4340701)
93 | P a g e
Advanced Object-Oriented Programming (4340701)
94 | P a g e
Advanced Object-Oriented Programming (4340701)
95 | P a g e
Advanced Object-Oriented Programming (4340701)
Date: ……………
Practical No: 11.
A. Objective:
*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.
PO7: Life-long learning: Ability to analyze individual needs and engage in updating
in the context of technological changes in field of engineering.
CO2: Use object oriented programming concepts to solve real world problems.
*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.
96 | P a g e
Advanced Object-Oriented Programming (4340701)
G. Prerequisite Theory:
In Java, method overloading is the process of defining multiple methods in the same class
with the same name but different parameters. When a method is called, the Java compiler
uses the number and type of arguments to determine which version of the method to call.
Here are some key points related to method overloading in Java:
Method overloading is a way to provide multiple methods with the same name in a
class, but with different argument lists.
When you call an overloaded method, the Java compiler matches the method
signature with the arguments passed in and decides which method to call.
The signature of a method includes the method name and the types and order of the
method's parameters. Return type and access modifier are not part of the method
signature.
Overloading can be used to simplify code and make it more readable by providing
methods with the same name and different parameters that perform related tasks.
You can overload constructors as well as regular methods.
Java does not allow you to overload methods based solely on their return type. If you
attempt to define two methods with the same name and parameter types but
different return types, you will get a compile-time error.
Java does not allow you to overload methods based solely on their access modifiers.
If you attempt to define two methods with the same name and parameter types but
different access modifiers, you will get a compile-time error.
97 | P a g e
Advanced Object-Oriented Programming (4340701)
When you call the add method on an instance of the Calculator class, the Java compiler uses
the number and types of the arguments passed in to determine which version of the method
to call. For example:
Calculator calc = new Calculator();
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification Quantity
No.
/Components/Trainer kit
1 Hardware: Computer System Computer (i3-i5 preferable),RAM Asper
mm1mum 2 GB and onwards batch size
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
98 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
99 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………………………………
……………………………………………..
K. Input-Output:
100 | P a g
e
Advanced Object-Oriented Programming (4340701)
M. References / Suggestions
https://www.w3schools.com/java/default.asp
https://www.javatpoint.com/java-tutorial
N. Assessment-Rubrics
Date: ……………
101 | P a g
e
Advanced Object-Oriented Programming (4340701)
102 | P a g
e
Advanced Object-Oriented Programming (4340701)
103 | P a g
e
Advanced Object-Oriented Programming (4340701)
104 | P a g
e
Advanced Object-Oriented Programming (4340701)
105 | P a g
e
Advanced Object-Oriented Programming (4340701)
A. Objective:
CO2: Use object oriented programming concepts to solve real world problems.
G. Prerequisite Theory:
Constructor overloading is the concept of having multiple constructors in a class, each with a
different set of parameters. This allows you to create objects of the same class using different
sets of values. Here's an example:
106 | P a g
e
Advanced Object-Oriented Programming (4340701)
H. Resources/Equipment Required
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
107 | P a g
e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
108 | P a g
e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………………………………
……………………………………………..
K. Input-Output:
109 | P a g
e
Advanced Object-Oriented Programming (4340701)
M. References / Suggestions
https://www.w3schools.com/java/default.asp
https://www.javatpoint.com/java-tutorial
N. Assessment-Rubrics
Date: ……………
110 | P a g
e
Advanced Object-Oriented Programming (4340701)
111 | P a g
e
Advanced Object-Oriented Programming (4340701)
112 | P a g
e
Advanced Object-Oriented Programming (4340701)
113 | P a g
e
Advanced Object-Oriented Programming (4340701)
114 | P a g
e
Advanced Object-Oriented Programming (4340701)
A. Objective:
Write a java program to demonstrate use of “String” class methods : chatAt(), contains(),
format(), length(), split()
CO2: Use object oriented programming concepts to solve real world problems.
Write a java program to demonstrate use of “String” class methods : chatAt(), contains(),
format(), length(), split()
G. Prerequisite Theory:
some important functions of the String class in Java:
115 | P a g
e
Advanced Object-Oriented Programming (4340701)
substring(): This method returns a substring of the string, starting from a specified index
and ending at a specified index.
indexOf(): This method returns the index of the first occurrence of a specified character
or substring in the string.
toUpperCase(): This method returns a new string with all the characters in uppercase.
toLowerCase(): This method returns a new string with all the characters in lowercase.
trim(): This method returns a new string with leading and trailing whitespace removed.
split(): This method splits the string into an array of substrings based on a specified
delimiter.
equals(): This method compares two strings for equality.
compareTo(): This method compares two strings lexicographically and returns an integer
value that indicates the result.
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification Quantity
No.
/Components/Trainer kit
1 Hardware: Computer System Computer (i3-i5 preferable),RAM Asper
mm1mum 2 GB and onwards batch size
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
116 | P a g
e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
117 | P a g
e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………………………………
……………………………………………..
K. Input-Output:
118 | P a g
e
Advanced Object-Oriented Programming (4340701)
M. References / Suggestions
https://www.w3schools.com/java/default.asp
https://www.javatpoint.com/java-tutorial
N. Assessment-Rubrics
Date: ……………
119 | P a g
e
Advanced Object-Oriented Programming (4340701)
120 | P a g
e
Advanced Object-Oriented Programming (4340701)
121 | P a g
e
Advanced Object-Oriented Programming (4340701)
122 | P a g
e
Advanced Object-Oriented Programming (4340701)
123 | P a g
e
Advanced Object-Oriented Programming (4340701)
A. Objective:
CO3: Develop an object-oriented program using inheritance and package concepts for a
given problem statement.
G. Prerequisite Theory:
class Animal {
124 | P a g
e
Advanced Object-Oriented Programming (4340701)
class Animal {
public void eat() {
System.out.println("Animal is eating");
}
}
class Animal {
public void eat() {
System.out.println("Animal is eating");
}
}
125 | P a g
e
Advanced Object-Oriented Programming (4340701)
Multiple inheritance (not available in Java): In multiple inheritance, a subclass inherits from
multiple superclasses. However, multiple inheritance is not supported in Java, as it can lead to
complications and conflicts.
These are just a few examples of the different types of inheritance in Java.
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification Quantity
No.
/Components/Trainer kit
1 Hardware: Computer System Computer (i3-i5 preferable),RAM Asper
mm1mum 2 GB and onwards batch size
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
126 | P a g
e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
127 | P a g
e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………………………………
……………………………………………..
K. Input-Output:
128 | P a g
e
Advanced Object-Oriented Programming (4340701)
M. References / Suggestions
https://www.w3schools.com/java/default.asp
https://www.javatpoint.com/java-tutorial
N. Assessment-Rubrics
129 | P a g
e
Advanced Object-Oriented Programming (4340701)
130 | P a g
e
Advanced Object-Oriented Programming (4340701)
131 | P a g
e
Advanced Object-Oriented Programming (4340701)
132 | P a g
e
Advanced Object-Oriented Programming (4340701)
133 | P a g
e
Advanced Object-Oriented Programming (4340701)
Date: ……………
Practical No: 15.
A. Objective:
CO3: Develop an object-oriented program using inheritance and package concepts for a
given problem statement.
G. Prerequisite Theory:
explained in Practical 14
134 | P a g
e
Advanced Object-Oriented Programming (4340701)
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification Quantity
No.
/Components/Trainer kit
1 Hardware: Computer System Computer (i3-i5 preferable),RAM Asper
mm1mum 2 GB and onwards batch size
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
135 | P a g
e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
136 | P a g
e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………………………………
……………………………………………..
K. Input-Output:
M. References / Suggestions
https://www.w3schools.com/java/default.asp
https://www.javatpoint.com/java-tutorial
137 | P a g
e
Advanced Object-Oriented Programming (4340701)
N. Assessment-Rubrics
138 | P a g
e
Advanced Object-Oriented Programming (4340701)
139 | P a g
e
Advanced Object-Oriented Programming (4340701)
140 | P a g
e
Advanced Object-Oriented Programming (4340701)
141 | P a g
e
Advanced Object-Oriented Programming (4340701)
142 | P a g
e
Advanced Object-Oriented Programming (4340701)
Date: ……………
Practical No: 16.
A. Objective:
CO3: Develop an object-oriented program using inheritance and package concepts for a
given problem statement.
G. Prerequisite Theory:
explained in Practical 14
143 | P a g
e
Advanced Object-Oriented Programming (4340701)
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification Quantity
No.
/Components/Trainer kit
1 Hardware: Computer System Computer (i3-i5 preferable),RAM Asper
mm1mum 2 GB and onwards batch size
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
144 | P a g
e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
145 | P a g
e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………………………………
……………………………………………..
K. Input-Output:
M. References / Suggestions
https://www.w3schools.com/java/default.asp
https://www.javatpoint.com/java-tutorial
146 | P a g
e
Advanced Object-Oriented Programming (4340701)
N. Assessment-Rubrics
147 | P a g
e
Advanced Object-Oriented Programming (4340701)
148 | P a g
e
Advanced Object-Oriented Programming (4340701)
149 | P a g
e
Advanced Object-Oriented Programming (4340701)
150 | P a g
e
Advanced Object-Oriented Programming (4340701)
151 | P a g
e
Advanced Object-Oriented Programming (4340701)
Date: ……………
A. Objective:
CO3: Develop an object-oriented program using inheritance and package concepts for a given
problem statement.
152 | P a g
e
Advanced Object-Oriented Programming (4340701)
G. Prerequisite Theory:
class Animal {
public void makeSound() {
System.out.println("Some sound");
}
}
In this example, we have a superclass Animal with a method makeSound() that prints "Some
sound". We then have a subclass Cat that extends Animal and overrides the makeSound()
method to print "Meow".
In the main method, we create an object of Animal and call its makeSound() method, which
prints "Some sound". We then create an object of Cat and call its makeSound() method,
153 | P a g
e
Advanced Object-Oriented Programming (4340701)
which
154 | P a g
e
Advanced Object-Oriented Programming (4340701)
prints "Meow". Finally, we create an object of Cat and assign it to a variable of type Animal.
When we call makeSound() on this variable, it still calls the makeSound() method of Cat and
prints "Meow", even though the variable is of type Animal. This is because the makeSound()
method is dynamically bound at runtime based on the type of the actual object being referred
to.
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification Quantity
No.
/Components/Trainer kit
1 Hardware: Computer System Computer (i3-i5 preferable),RAM Asper
mm1mum 2 GB and onwards batch size
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
155 | P a g
e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
156 | P a g
e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………………………………
……………………………………………..…………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
157 | P a g
e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
……………………………………………………………………..…..……………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………………………………………………………………………………………...………
K. Input-Output:
158 | P a g
e
Advanced Object-Oriented Programming (4340701)
M. References / Suggestions
https://www.w3schools.com/java/java_inheritance.asp
https://www.javatpoint.com/inheritance-in-java
N. Assessment-Rubrics
159 | P a g
e
Advanced Object-Oriented Programming (4340701)
160 | P a g
e
Advanced Object-Oriented Programming (4340701)
161 | P a g
e
Advanced Object-Oriented Programming (4340701)
162 | P a g
e
Advanced Object-Oriented Programming (4340701)
163 | P a g
e
Advanced Object-Oriented Programming (4340701)
Date: ……………
A. Objective:
*Write a program in Java which has a class Car having two instance variables topSpeed and
name. Override toString() method in Car class. Create 5 instances of Car class and print the
instances.
CO3: Develop an object-oriented program using inheritance and package concepts for a given
problem statement.
*Write a program in Java which has a class Car having two instance variables topSpeed and
name. Override toString() method in Car class. Create 5 instances of Car class and print the
instances.
G. Prerequisite Theory:
164 | P a g
e
Advanced Object-Oriented Programming (4340701)
Method Description
public int hashCode() returns the hashcode number for this object.
protected Object clone() throws creates and returns the exact copy (clone) of
CloneNotSupportedException this object.
165 | P a g
e
Advanced Object-Oriented Programming (4340701)
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification Quantity
No.
/Components/Trainer kit
1 Hardware: Computer System Computer (i3-i5 preferable),RAM Asper
mm1mum 2 GB and onwards batch size
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
166 | P a g
e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
167 | P a g
e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………….……………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………
K. Input-Output:
168 | P a g
e
Advanced Object-Oriented Programming (4340701)
M. References / Suggestions
https://www.w3schools.com/java/java_inheritance.asp
https://www.javatpoint.com/inheritance-in-java
N. Assessment-Rubrics
169 | P a g e
Advanced Object-Oriented Programming (4340701)
170 | P a g e
Advanced Object-Oriented Programming (4340701)
171 | P a g e
Advanced Object-Oriented Programming (4340701)
172 | P a g e
Advanced Object-Oriented Programming (4340701)
173 | P a g e
Advanced Object-Oriented Programming (4340701)
Date: ……………
A. Objective:
CO3: Develop an object-oriented program using inheritance and package concepts for a given
problem statement.
G. Prerequisite Theory:
174 | P a g e
Advanced Object-Oriented Programming (4340701)
Before diving into multiple inheritance using interfaces in Java, it's essential to understand
the following concepts:
H. Resources/Equipment Required
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
175 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
176 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
K. Input-Output:
177 | P a g e
Advanced Object-Oriented Programming (4340701)
M. References / Suggestions
https://www.w3schools.com/java/java_inheritance.asp
https://www.javatpoint.com/inheritance-in-java
N. Assessment-Rubrics
178 | P a g e
Advanced Object-Oriented Programming (4340701)
179 | P a g e
Advanced Object-Oriented Programming (4340701)
180 | P a g e
Advanced Object-Oriented Programming (4340701)
181 | P a g e
Advanced Object-Oriented Programming (4340701)
182 | P a g e
Advanced Object-Oriented Programming (4340701)
183 | P a g e
Advanced Object-Oriented Programming (4340701)
Date: ……………
A. Objective:
*Write a program in Java which has an abstract class Shape having three subclasses:
Triangle, Rectangle, and Circle. Define method area() in the abstract class Shape and
override area() method to calculate the area.
PO7: Life-long learning: Ability to analyze individual needs and engage in updating
in the context of technological changes in field of engineering.
CO3: Develop an object-oriented program using inheritance and package concepts for a given
problem statement.
*Write a program in Java which has an abstract class Shape having three subclasses: Triangle,
Rectangle, and Circle. Define method area() in the abstract class Shape and override area()
method to calculate the area.
184 | P a g e
Advanced Object-Oriented Programming (4340701)
G. Prerequisite Theory:
In Java, an abstract class is a class that cannot be instantiated, meaning that you cannot
create an object of this class directly. Instead, you need to create a subclass that extends the
abstract class and implements its abstract methods to create an instance.
An abstract class is declared using the abstract keyword. It may contain both abstract and
non- abstract methods. An abstract method is a method that is declared but does not have an
implementation in the abstract class. The implementation is left to the subclasses that extend
the abstract class. Abstract methods are declared using the abstract keyword and end with a
semicolon instead of a method body.
Here is an example of an abstract class in Java:
Abstract classes are useful when you want to define a common interface for a group of
related classes. By defining the common interface in an abstract class, you can ensure that all
the subclasses have a consistent set of methods and properties, while still allowing each
subclass to provide its own implementation.
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification Quantity
No.
/Components/Trainer kit
1 Hardware: Computer System Computer (i3-i5 preferable),RAM Asper
mm1mum 2 GB and onwards batch size
185 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
186 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………
187 | P a g e
Advanced Object-Oriented Programming (4340701)
K. Input-Output:
M. References / Suggestions
https://www.javatpoint.com/abstract-class-in-java
https://www.w3schools.com/java/java_abstract.asp
https://www.geeksforgeeks.org/abstract-classes-in-java/
188 | P a g e
Advanced Object-Oriented Programming (4340701)
N. Assessment-Rubrics
189 | P a g e
Advanced Object-Oriented Programming (4340701)
190 | P a g e
Advanced Object-Oriented Programming (4340701)
191 | P a g e
Advanced Object-Oriented Programming (4340701)
192 | P a g e
Advanced Object-Oriented Programming (4340701)
193 | P a g e
Advanced Object-Oriented Programming (4340701)
Date: ……………
A. Objective:
CO3: Develop an object-oriented program using inheritance and package concepts for a given
problem statement.
194 | P a g e
Advanced Object-Oriented Programming (4340701)
G. Prerequisite Theory:
In Java, a final class is a class that cannot be subclassed or extended. This means that once a
class is declared as final, it cannot be inherited by any other class, and no subclass can be
created from it.
To declare a class as final, use the final keyword in the class declaration, like this:
When used with a method, the final keyword prevents the method from being
overridden by any subclass.
When used with a variable, the final keyword indicates that the variable's value
cannot be changed after it has been initialized.
H. Resources/Equipment Required
195 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
196 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………
197 | P a g e
Advanced Object-Oriented Programming (4340701)
K. Input-Output:
M. References / Suggestions
https://www.tutorialspoint.com/What-are-final-classes-in-Java
https://www.javatpoint.com/final-keyword
198 | P a g e
Advanced Object-Oriented Programming (4340701)
N. Assessment-Rubrics
199 | P a g e
Advanced Object-Oriented Programming (4340701)
200 | P a g e
Advanced Object-Oriented Programming (4340701)
201 | P a g e
Advanced Object-Oriented Programming (4340701)
202 | P a g e
Advanced Object-Oriented Programming (4340701)
203 | P a g e
Advanced Object-Oriented Programming (4340701)
Date: ……………
A. Objective:
CO3: Develop an object-oriented program using inheritance and package concepts for a given
problem statement.
G. Prerequisite Theory:
204 | P a g e
Advanced Object-Oriented Programming (4340701)
In Java, a package is a mechanism that allows you to group related classes, interfaces, and
sub- packages together. It provides a way to organize and manage your Java code, making it
easier to maintain and reuse.
A package is declared using the package keyword, followed by the package name, at the
beginning of a Java file. For example, if you wanted to create a package called
"com.example.myapp", you would declare it like this:
package com.example.myapp;
// Java code here
Packages are typically organized in a hierarchical structure, with sub-packages and classes
within them. For example, the package name "com.example.myapp" might contain several
sub- packages, such as "com.example.myapp.ui" and "com.example.myapp.model", each of
which contains related classes and interfaces.
To use classes from a different package in your Java code, you need to import them using the
import statement. For example, if you wanted to use the MyClass class from the
"com.example.myapp.model" package in your code, you would import it like this:
import com.example.myapp.model.MyClass;
Using packages in your Java code can provide several benefits, including:
205 | P a g e
Advanced Object-Oriented Programming (4340701)
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification Quantity
No.
/Components/Trainer kit
1 Hardware: Computer System Computer (i3-i5 preferable),RAM Asper
mm1mum 2 GB and onwards batch size
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
206 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
207 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………
K. Input-Output:
208 | P a g e
Advanced Object-Oriented Programming (4340701)
M. References / Suggestions
https://www.javatpoint.com/package
https://www.w3schools.com/java/java_packages.asp
https://www.geeksforgeeks.org/packages-in-java/
N. Assessment-Rubrics
209 | P a g e
Advanced Object-Oriented Programming (4340701)
210 | P a g e
Advanced Object-Oriented Programming (4340701)
211 | P a g e
Advanced Object-Oriented Programming (4340701)
212 | P a g e
Advanced Object-Oriented Programming (4340701)
213 | P a g e
Advanced Object-Oriented Programming (4340701)
Date: ……………
A. Objective:
Write a program in Java to develop user defined exception for 'Divide by Zero' error.
CO4: Develop an object oriented program using multithreading and exception handling for a
given problem statement.
Write a program in Java to develop user defined exception for 'Divide by Zero' error.
214 | P a g e
Advanced Object-Oriented Programming (4340701)
G. Prerequisite Theory:
This class extends the Exception class and adds a constructor that takes a String message
parameter. This message can be used to provide more information about the error condition
that caused the exception to be thrown.
Once you have defined your custom exception class, you can throw it like any other exception
in your Java code. For example, if you wanted to throw an InvalidInputException when the
user enters invalid data into a form, you might write code like this:
This code checks if the input is empty or null, and throws an InvalidInputException if it is. This
if (input == null || input.isEmpty()) {
throw new InvalidInputException("Input cannot be empty");
}
exception can then be caught and handled by other parts of the application, using standard
Java exception handling techniques.
215 | P a g e
Advanced Object-Oriented Programming (4340701)
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification Quantity
No.
/Components/Trainer kit
1 Hardware: Computer System Computer (i3-i5 preferable),RAM Asper
mm1mum 2 GB and onwards batch size
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
216 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
217 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..………………………………………………………………………….………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………
K. Input-Output:
218 | P a g e
Advanced Object-Oriented Programming (4340701)
M. References / Suggestions
https://www.geeksforgeeks.org/exceptions-in-java/
https://www.tutorialspoint.com/java/java_exceptions.htm
https://www.w3schools.com/java/java_try_catch.asp
N. Assessment-Rubrics
219 | P a g e
Advanced Object-Oriented Programming (4340701)
220 | P a g e
Advanced Object-Oriented Programming (4340701)
221 | P a g e
Advanced Object-Oriented Programming (4340701)
222 | P a g e
Advanced Object-Oriented Programming (4340701)
223 | P a g e
Advanced Object-Oriented Programming (4340701)
Date: ……………
A. Objective:
*Write a program in Java to develop Banking Application in which user deposits the amount
Rs 25000 and then start withdrawing of Rs 20000, Rs 4000 and it throws exception "Not
Sufficient Fund" when user withdraws Rs. 2000 thereafter.
PO7: Life-long learning: Ability to analyze individual needs and engage in updating
in the context of technological changes in field of engineering.
CO4: Develop an object oriented program using multithreading and exception handling for a
given problem statement.
224 | P a g e
Advanced Object-Oriented Programming (4340701)
*Write a program in Java to develop Banking Application in which user deposits the amount
Rs 25000 and then start withdrawing of Rs 20000, Rs 4000 and it throws exception "Not
Sufficient Fund" when user withdraws Rs. 2000 thereafter.
G. Prerequisite Theory:
In Java, a runtime exception is a type of exception that can occur at any time during program
execution, and does not need to be explicitly declared in the method signature or caught in
a try-catch block. Some common examples of runtime exceptions in Java include
NullPointerException, ArrayIndexOutOfBoundsException, and ArithmeticException.
You can use the throw keyword in Java to manually generate runtime exceptions, by
throwing an instance of a runtime exception class. For example, if you wanted to throw an
IllegalArgumentException when a method is called with an invalid argument, you might
write code like this:
This code checks if the argument is negative, and throws an IllegalArgumentException with a
custom error message if it is. This exception can then be caught and handled by other parts
of the application, using standard Java exception handling techniques.
if (argument < 0) {
thrownewIllegalArgumentException("Argumentcannotbe negative");
}
225 | P a g e
Advanced Object-Oriented Programming (4340701)
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification Quantity
No.
/Components/Trainer kit
1 Hardware: Computer System Computer (i3-i5 preferable),RAM Asper
mm1mum 2 GB and onwards batch size
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
226 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
227 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………………………….……
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………
K. Input-Output:
228 | P a g e
Advanced Object-Oriented Programming (4340701)
M. References / Suggestions
https://www.geeksforgeeks.org/exceptions-in-java/
https://www.tutorialspoint.com/java/java_exceptions.htm
https://www.w3schools.com/java/java_try_catch.asp
N. Assessment-Rubrics
Performance Indicators Weightage
Process related (15 Marks) 70%
1. Logic formation 30%
2. Debugging ability 30%
3. Follow ethical practices 10%
Product related (10 Marks) 30%
4. Expected output 10%
5. Timely Submission of report 10%
229 | P a g e
Advanced Object-Oriented Programming (4340701)
230 | P a g e
Advanced Object-Oriented Programming (4340701)
231 | P a g e
Advanced Object-Oriented Programming (4340701)
232 | P a g e
Advanced Object-Oriented Programming (4340701)
233 | P a g e
Advanced Object-Oriented Programming (4340701)
Date: ……………
A. Objective:
*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
CO4: Develop an object oriented program using multithreading and exception handling for a
given problem statement.
*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
234 | P a g e
Advanced Object-Oriented Programming (4340701)
G. Prerequisite Theory:
Java threading is the process of creating and managing threads within a Java program. A
thread is a lightweight sub-process that can run concurrently with other threads, sharing the
same memory and resources of the main program.
In Java, you can create a thread by either extending the Thread class or implementing the
Runnable interface. When you extend the Thread class, you override the run() method, which
is the entry point for the thread. When you implement the Runnable interface, you need to
define the run() method in a separate class, and then create a new Thread object passing it
the Runnable instance.
Here's an example of creating a thread by extending the Thread class:
In this example, the MyThread class extends the Thread class and overrides the run() method,
which is the entry point for the thread. When the start() method is called, a new thread is
created and the run() method is executed in that thread.
When the start() method is called, the run() method of the MyRunnable instance is executed
in a separate thread.
235 | P a g e
Advanced Object-Oriented Programming (4340701)
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification Quantity
No.
/Components/Trainer kit
1 Hardware: Computer System Computer (i3-i5 preferable),RAM Asper
mm1mum 2 GB and onwards batch size
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
236 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
237 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………
K. Input-Output:
238 | P a g e
Advanced Object-Oriented Programming (4340701)
M. References / Suggestions
https://www.w3schools.com/java/java_threads.asp
https://www.javatpoint.com/multithreading-in-java
https://www.geeksforgeeks.org/multithreading-in-java/
N. Assessment-Rubrics
239 | P a g e
Advanced Object-Oriented Programming (4340701)
240 | P a g e
Advanced Object-Oriented Programming (4340701)
241 | P a g e
Advanced Object-Oriented Programming (4340701)
242 | P a g e
Advanced Object-Oriented Programming (4340701)
243 | P a g e
Advanced Object-Oriented Programming (4340701)
244 | P a g e
Advanced Object-Oriented Programming (4340701)
Date: ……………
A. Objective:
Write a program that executes two threads. One thread will print the even numbers and
another thread will print odd numbers from 1 to 200.
CO4: Develop an object oriented program using multithreading and exception handling for a
given problem statement.
Write a program that executes two threads. One thread will print the even numbers and
another thread will print odd numbers from 1 to 200.
245 | P a g e
Advanced Object-Oriented Programming (4340701)
G. Prerequisite Theory:
Creating a thread by implementing the Runnable interface:
H. Resources/Equipment Required
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
246 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
247 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………………………………
……………………………………………..
K. Input-Output:
248 | P a g e
Advanced Object-Oriented Programming (4340701)
M. References / Suggestions
https://www.w3schools.com/java/java_threads.asp
https://www.javatpoint.com/multithreading-in-java
https://www.geeksforgeeks.org/multithreading-in-java/
N. Assessment-Rubrics
249 | P a g e
Advanced Object-Oriented Programming (4340701)
250 | P a g e
Advanced Object-Oriented Programming (4340701)
251 | P a g e
Advanced Object-Oriented Programming (4340701)
252 | P a g e
Advanced Object-Oriented Programming (4340701)
253 | P a g e
Advanced Object-Oriented Programming (4340701)
Date: ……………
A. Objective:
*Write a program in Java to perform read and write operations on a Text file.
PO7: Life-long learning: Ability to analyze individual needs and engage in updating
in the context of technological changes in field of engineering.
CO5: Develop an object-oriented program by using the files and collection framework.
*Write a program in Java to perform read and write operations on a Text file.
254 | P a g e
Advanced Object-Oriented Programming (4340701)
G. Prerequisite Theory:
The java.io package in Java provides a set of classes and interfaces for handling input and
output operations. It is used for reading and writing data to and from different types of
sources such as files, streams, and network connections.
255 | P a g e
Advanced Object-Oriented Programming (4340701)
import java.io.FileInputStream;
import java.io.IOException;
H. Resources/Equipment Required
256 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
257 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………………………………
……………………………………………..
K. Input-Output:
258 | P a g e
Advanced Object-Oriented Programming (4340701)
M. References / Suggestions
https://www.geeksforgeeks.org/file-handling-in-java/
https://www.javatpoint.com/file-operations-in-java
https://www.w3schools.com/java/java_files.asp
N. Assessment-Rubrics
259 | P a g e
Advanced Object-Oriented Programming (4340701)
260 | P a g e
Advanced Object-Oriented Programming (4340701)
261 | P a g e
Advanced Object-Oriented Programming (4340701)
262 | P a g e
Advanced Object-Oriented Programming (4340701)
263 | P a g e
Advanced Object-Oriented Programming (4340701)
Date: ……………
A. Objective:
CO5: Develop an object-oriented program by using the files and collection framework.
264 | P a g e
Advanced Object-Oriented Programming (4340701)
G. Prerequisite Theory:
ArrayList:
ArrayList is a resizable array implementation of the List interface in Java. It allows you to add
and remove elements dynamically, making it useful when you need to add or remove
elements from a collection frequently. It uses an array to store elements, and when the
array is full, it creates a new array with a larger size to accommodate more elements. This
resizing operation can be costly in terms of performance, especially for large collections.
However, accessing elements in an ArrayList is very fast because it uses an index-based
approach.
LinkedList:
LinkedList is a doubly-linked list implementation of the List interface in Java. Unlike ArrayList,
it does not use an array to store elements. Instead, it uses a series of nodes, where each
node contains a reference to the previous and next nodes. This makes it more efficient than
ArrayList for adding or removing elements, especially in the middle of the list. However,
accessing elements in a LinkedList can be slower than ArrayList because it does not use an
index-based approach. Instead, it needs to traverse the list to find the element.
ArrayList Example:
import java.util.ArrayList;
Output:
LinkedList Example:
import java.util.LinkedList;
Output:
266 | P a g e
Advanced Object-Oriented Programming (4340701)
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification Quantity
No.
/Components/Trainer kit
1 Hardware: Computer System Computer (i3-i5 preferable),RAM Asper
mm1mum 2 GB and onwards batch size
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
267 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
268 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………………………….……
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………
K. Input-Output:
269 | P a g e
Advanced Object-Oriented Programming (4340701)
M. References / Suggestions
https://www.w3schools.com/java/java_arraylist.asp
https://www.w3schools.com/java/java_linkedlist.asp
https://www.javatpoint.com/collections-in-java
https://www.geeksforgeeks.org/collections-in-java-2/
N. Assessment-Rubrics
270 | P a g e
Advanced Object-Oriented Programming (4340701)
271 | P a g e
Advanced Object-Oriented Programming (4340701)
272 | P a g e
Advanced Object-Oriented Programming (4340701)
273 | P a g e
Advanced Object-Oriented Programming (4340701)
274 | P a g e
Advanced Object-Oriented Programming (4340701)
Date: ……………
A. Objective:
Write a program in Java to create a new HashSet, add colors(in string form) and iterate
through all elements using for-each loop to display the collection.
CO5: Develop an object-oriented program by using the files and collection framework.
Write a program in Java to create a new HashSet, add colors(in string form) and iterate through
all elements using for-each loop to display the collection.
G. Prerequisite Theory:
275 | P a g e
Advanced Object-Oriented Programming (4340701)
Java Collection HashSet is a class that implements the Set interface and represents an
unordered collection of unique elements, where duplicates are not allowed. The elements
are stored using a hash table, which provides constant time performance for basic
operations such as add, remove, and contains.
Here's an example of how to use HashSet in Java:
import java.util.HashSet;
276 | P a g e
Advanced Object-Oriented Programming (4340701)
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification Quantity
No.
/Components/Trainer kit
1 Hardware: Computer System Computer (i3-i5 preferable),RAM Asper
mm1mum 2 GB and onwards batch size
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
277 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
278 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………………….……………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………
K. Input-Output:
279 | P a g e
Advanced Object-Oriented Programming (4340701)
M. References / Suggestions
https://www.w3schools.com/java/java_hashset.asp
https://www.javatpoint.com/collections-in-java
https://www.geeksforgeeks.org/collections-in-java-2/
N. Assessment-Rubrics
280 | P a g e
Advanced Object-Oriented Programming (4340701)
281 | P a g e
Advanced Object-Oriented Programming (4340701)
282 | P a g e
Advanced Object-Oriented Programming (4340701)
283 | P a g e
Advanced Object-Oriented Programming (4340701)
284 | P a g e
Advanced Object-Oriented Programming (4340701)
Date: ……………
A. Objective:
*Write a Java program to create a new HashMap, add 5 students’ data (enrolment no and
name). retrieve and display the student’s name from HashMap using enrolment no.
PO7: Life-long learning: Ability to analyze individual needs and engage in updating
in the context of technological changes in field of engineering.
CO5: Develop an object-oriented program by using the files and collection framework.
*Write a Java program to create a new HashMap, add 5 students’ data (enrolment no and
name). retrieve and display the student’s name from HashMap using enrolment no.
285 | P a g e
Advanced Object-Oriented Programming (4340701)
G. Prerequisite Theory:
Java Collection HashMap is a class that implements the Map interface and represents a
collection of key-value pairs, where each key is unique and maps to a corresponding value.
The elements are stored using a hash table, which provides constant time performance for
basic operations such as put, get, and remove.
Here's an example of how to use HashMap in Java:
import java.util.HashMap;
286 | P a g e
Advanced Object-Oriented Programming (4340701)
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification Quantity
No.
/Components/Trainer kit
1 Hardware: Computer System Computer (i3-i5 preferable),RAM Asper
mm1mum 2 GB and onwards batch size
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
287 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
288 | P a g e
Advanced Object-Oriented Programming (4340701)
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
…………………………………………………………………………………………………………………………………………………
………………………………………………………..…..…………………………………………………………………………………
……………………………………………..
K. Input-Output:
289 | P a g e
Advanced Object-Oriented Programming (4340701)
M. References / Suggestions
https://www.w3schools.com/java/java_hashmap.asp
https://www.javatpoint.com/collections-in-java
https://www.geeksforgeeks.org/collections-in-java-2/
N. Assessment-Rubrics
290 | P a g e