java_sem4_parth(10)
java_sem4_parth(10)
DTE’s Vision:
Institute’s Vision:
Institute’s Mission:
Department’s Vision:
Department’s Mission:
Certificate
This is to certify that Mr./Ms.…………………………………………………….…………………..….
in.....…….………………..………..…………………………………………………….…………………………………
of
Institute,...…………………………………………………………..........................................................
... (GTU Code: ………...…...) has satisfactorily completed the term work satisfactorily in
course Object Oriented Programming with JAVA –4341602 for the academic
Place: ……………………….……
Date: …………………………..…
Preface
The primary aim of any laboratory/Practical/field work is for enhancing required skills as well as
creating ability amongst students to solve real time problem by developing relevant competencies
in psychomotor domain. By keeping in view, GTU has designed competency focused outcomebased
curriculum-2021 (COGC-2021) for engineering diploma programmers. In this more time allotted to
practical work than theory. It shows importance of enhancement of skills amongst students and it
pays attention to utilize every seconds of time allotted for practical amongst students, instructors
and Lecturers to achieve relevant outcomes by performing rather than writing practice in study type.
It is essential for effective implementation of competency focused outcome-based green
curriculum-2021, every practical has been keenly designed to serve as a tool to develop & enhance
relevant industry needed competency in each and every student. These psychomotor skills are very
difficult to develop through traditional chalk and board content delivery method in the classroom.
Accordingly, this lab manual designed to focus on the industry defined relevant outcomes, rather
than old practice of conducting practical to prove concept and theory.
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 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
practical.
This manual also provides guidelines to lecturers to facilitate student-centered lab activities through
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.
Object oriented programming with JAVA course develop a depth understating about programming
paradigm, object orients programming concept like Inheritance, Encapsulation, Abstraction,
polymorphism etc. In the current industrial scenario JAVA has broad industry support and
prerequisite to many technologies. After learning this course student can write/develop platform
independent, object-oriented application using JAVA.
Although we try our level best to design this lab manual, but always there are chances of
improvement. We welcome any suggestions for improvement.
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.
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 in field of engineering.
The following industry relevant skills of the competency “Develop a program using object-oriented
programming concepts with java to solve the given problems.” are expected to be developed in the
student by undertaking the practical of this laboratory manual.
Guidelines to Teachers
1. Course faculty should demonstrate experiment with all necessary implementation strategies
described in curriculum.
2. Course faculty should explain industrial relevance before starting of each experiment.
3. Course faculty should involve& give opportunity to all students for hands on experience.
4. Course faculty should ensure mentioned skills are developed in the students’ byasking.
5. Utilize 2 hrs. of lab hours effectively and ensure completion of write up with quiz also.
6. Encourage peer to peer learning by doing same experiment through fast learners.
1. Organize the work in the group and make record of all observations.
2. Students shall develop maintenance skill as expected by industries.
3. Student shall attempt to develop related hand-on skills and build confidence.
4. Student shall develop the habits of evolving more ideas, innovations, skills etc.
5. Student shall refer technical magazines and data books.
6. Student should develop habit to submit the practical on date and time.
7. Student should well prepare while submitting write-up of exercise.
Index
(Continuous Assessment Sheet)
Develop a basic java program that demonstrates the use of Class &
8
Object.
Develop a program with a static block and show that it will be executed
13
before the main() method in a class.
IT-SEM 4-A 10 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Develop a program with one class named shape which has two member
functions named erase () and draw(). In the program we have three other
19
subclasses: circle, triangle and square. Override methods of the super
class into sub classes.
IT-SEM 4-A 11 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Develop a program that executes two threads. One thread displays “Java
29 Programming” every 2 seconds, and the other displays “Semester - 4th”
every 5 seconds. (Create the threads by extending the Thread class)
Develop a program that executes two threads. One thread will print the
30 even numbers and another thread will print odd numbers between 1 to
10. (Create the thread by implementing runnable interface)
IT-SEM 4-A 12 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
PRACTICAL-1
• Now click on the x64 installer and download and install this in your PC or laptop.
IT-SEM 4-A 13 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 14 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 15 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 16 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 17 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Practical – 2
IT-SEM 4-A 18 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 19 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Practical-3
➢ Develop a basic java program that demonstrates data types of JAVA.
IT-SEM 4-A 20 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Output:
IT-SEM 4-A 21 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 22 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
PRACTICAL-4
IT-SEM 4-A 23 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
OUTPUT:-
IT-SEM 4-A 24 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 25 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
PRACTICAL :- 5
➢ Develop programs to demonstrate use of - if statement and its different form
switch case statement .
1.
IT-SEM 4-A 26 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
2.
OUTPUT :-
1.
IT-SEM 4-A 27 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
2.
IT-SEM 4-A 28 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 29 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
PRACTICAL:- 6
IT-SEM 4-A 30 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
OUTPUT :-
IT-SEM 4-A 31 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 32 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
PRACTICAL :-7
➢ Develop a Java program to find maximum and minimum numbers from array
elements.
IT-SEM 4-A 33 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
OUTPUT :-
IT-SEM 4-A 34 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 35 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Practical:-8
➢ Develop a basic java program that demonstrates the use of Class &
Object.
IT-SEM 4-A 36 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Output:-
IT-SEM 4-A 37 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 38 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Practical :-9
➢ Develop a java program to find the factorial of a given number using
a recursive function.
IT-SEM 4-A 39 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
OUTPUT:-
IT-SEM 4-A 40 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 41 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Practical :-10
➢ Develop a java program that demonstrates method overloading.
Ou
output :-
IT-SEM 4-A 42 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 43 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Practical:-11
➢ Develop a program for implementation of different functions of
String class.
IT-SEM 4-A 44 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Output :-
IT-SEM 4-A 45 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 46 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Practical :- 12
Output:-
IT-SEM 4-A 47 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 48 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Practical :- 13
➢ Develop a program with a static block and show that it will be
executed before the main() method in a class.
Output:-
IT-SEM 4-A 49 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 50 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Practical :-14
➢ Develop a program to demonstrate use of static functions.
Output:-
IT-SEM 4-A 51 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 52 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Practical :- 15
➢ Develop a program to demonstrate use of ‘this’ keyword. Check
whether ‘this’ can access the private members of the class or not.
IT-SEM 4-A 53 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Output:-
IT-SEM 4-A 54 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 55 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Practical :- 16
➢ Develop a program with an overloaded constructor. Also develop the
copy constructor to create a new object with the state of the existing
object.
IT-SEM 4-A 56 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Output :-
IT-SEM 4-A 57 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 58 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Practical :- 17
➢ Develop a program to demonstrate the use of private constructor and
also write a method which will count the number of instances created
using default constructor only.
Output :-
IT-SEM 4-A 59 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 60 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
PRACTICAL :- 18
➢ Develop a program to demonstrate single inheritance, multilevel inheritance,
and hierarchical inheritance.
INPUT:-
IT-SEM 4-A 61 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
OUTOUT:-
IT-SEM 4-A 62 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 63 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
PRACTICAL N0:-19
➢ Develop a program with one class named shape which has two
member functions named erase () and draw(). In the program we
have three other subclasses: circle, triangle and square. Override
methods of the super class into sub classes.
ZZZ
IT-SEM 4-A 64 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
OUTPUT:-
IT-SEM 4-A 65 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 66 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
PRACTICAL NO:-20
➢ Develop a program for implementation of Dynamic method dispatch.
INPUT:-
IT-SEM 4-A 67 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
OUTPUT:-
IT-SEM 4-A 68 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 69 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
PRACTICAL NO :-21
➢ Develop a java program that demonstrates the use of Abstract class.
INPUT:-
IT-SEM 4-A 70 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
OUTPUT:-
IT-SEM 4-A 71 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 72 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
PRACTICAL NO :-22
➢ Develop a java program that illustrates interface inheritance.
Interface ‘A1’ and ‘A2’ are extended from interface ‘A’. Interface
‘A12’ inherited from both ‘A1’ and ‘A2’. Each interface declares one
method and one constant. Class ‘Interface_Imple’ implements ‘A12’.
Instantiate ‘Interface_Imple’ and invoke each of its methods. Each
method displays one of the constants.
Input :-
IT-SEM 4-A 73 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 74 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Output :-
IT-SEM 4-A 75 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 76 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Practical no :- 23
➢ Develop a program to create a Package and demonstrate how
packages are used in java. and use java access modifier to
demonstrate the access rules in a package.
Input:-
IT-SEM 4-A 77 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Output:-
IT-SEM 4-A 78 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 79 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Practical no :-24
IT-SEM 4-A 80 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Output :-
IT-SEM 4-A 81 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 82 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Practical :-25
Input:-
IT-SEM 4-A 83 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Output :-
IT-SEM 4-A 84 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 85 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Practical :-26
Input:-
IT-SEM 4-A 86 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Output:-
IT-SEM 4-A 87 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 88 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Practical :- 27
Input:-
IT-SEM 4-A 89 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Output:-
IT-SEM 4-A 90 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 91 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Practical :-28
➢ Develop a program to demonstrate use of throw, throws, and finally
keyword.
Input :-
IT-SEM 4-A 92 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Output :-
IT-SEM 4-A 93 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 94 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Practical :-29
➢ Develop a program that executes two threads. One thread displays
“Java Programming” every 2 seconds, and the other displays
“Semester - 4th” every 5 seconds. (Create the threads by extending
the Thread class)
Input :-
IT-SEM 4-A 95 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Output :-
IT-SEM 4-A 96 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
IT-SEM 4-A 97 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Practical :- 30
➢ Develop a program that executes two threads. One thread will print
the even numbers and another thread will print odd numbers between
1 to 10. (Create the thread by implementing runnable interface)
Input :-
IT-SEM 4-A 98 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Output :-
IT-SEM 4-A 99 | P a g e
236170316008 Object Oriented Programming with JAVA (4341602)
Practical :-31
➢ Develop a program to demonstrate use of synchronization of threads
when multiple threads are trying to update a common variable.
Input :-
Output :-
Practical :- 32
➢ Develop programs to create, write, modify, read operations on Text
files.
Input:-
Output :-