Lab-Manual (Programming in Java)
Lab-Manual (Programming in Java)
Lab-Manual (Programming in Java)
Programming in Java L T P C
Subject Code
Total Contact Hours: 32 Hours 0 0 3 1.5
CSP-218
Prerequisite: Programming in C++
Marks-100
Internal-60 External-40
Course Objectives
Learn about the flaws in C/C++ and how java overcomes them
Understand the concept of OOPs and implement them with Java
Understand how frameworks and collections can be used in Java
Understand the multithreading and database connectivity concept.
Unit Course Outcomes
List of Experiments
UNIT-I
Java Basics
1. Write a program to check the entered number is even or odd.
2. Write a program to check the entered number is even or odd without using
I. modules operator.
3. Write a java Program to swap two numbers without using 3rd variable.
4. Write a java program to find factorial of a given number.
1. Write a program to initialize an integer array and print the sum and
average of the array.
II.
2. Write a program to find all prime numbers within a given range.
3. Write a program to check the entered number is perfect no or not.
Write a Java program to illustrate the use of Class, Object and Constructor.
III.
Create a class named ‘Animal’ which includes methods like eat() and sleep().
Create a child class of Animal named ‘Bird’ and override the parent class
methods. Add a new method named fly().
Create an instance of Animal class and invoke the eat and sleep methods using
IV.
this object.
Create an instance of Bird class and invoke the eat, sleep and fly methods using
this object.
UNIT -II
UNIT-III
Java Program to create threads using Thread Class and Runnable Interface.
VIII Create two threads and assign names ‘Thread1’ and ‘Thread2’ to the two threads.
Display both thread names.
Create an ArrayList that can store only Strings.
IX Create a printAll method that will print all the elements of the ArrayList using
an Iterator.
X Write a Java Program to insert the Student details into database using JDBC.